Reduce requested chapter data in queries
This commit is contained in:
84
src/lib/graphql/fragments/ChapterFragments.ts
Normal file
84
src/lib/graphql/fragments/ChapterFragments.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
const MANGA_BASE_FIELDS = gql`
|
||||
fragment MANGA_BASE_FIELDS on MangaType {
|
||||
id
|
||||
title
|
||||
|
||||
thumbnailUrl
|
||||
thumbnailUrlLastFetched
|
||||
|
||||
inLibrary
|
||||
initialized
|
||||
}
|
||||
`;
|
||||
|
||||
export const CHAPTER_BASE_FIELDS = gql`
|
||||
fragment CHAPTER_BASE_FIELDS on ChapterType {
|
||||
id
|
||||
name
|
||||
|
||||
mangaId
|
||||
scanlator
|
||||
realUrl
|
||||
|
||||
sourceOrder
|
||||
chapterNumber
|
||||
}
|
||||
`;
|
||||
|
||||
export const CHAPTER_STATE_FIELDS = gql`
|
||||
fragment CHAPTER_STATE_FIELDS on ChapterType {
|
||||
id
|
||||
isRead
|
||||
isDownloaded
|
||||
isBookmarked
|
||||
}
|
||||
`;
|
||||
|
||||
export const CHAPTER_READER_FIELDS = gql`
|
||||
${CHAPTER_BASE_FIELDS}
|
||||
${CHAPTER_STATE_FIELDS}
|
||||
|
||||
fragment CHAPTER_READER_FIELDS on ChapterType {
|
||||
...CHAPTER_BASE_FIELDS
|
||||
...CHAPTER_STATE_FIELDS
|
||||
|
||||
lastPageRead
|
||||
pageCount
|
||||
}
|
||||
`;
|
||||
|
||||
export const CHAPTER_LIST_FIELDS = gql`
|
||||
${CHAPTER_BASE_FIELDS}
|
||||
${CHAPTER_STATE_FIELDS}
|
||||
|
||||
fragment CHAPTER_LIST_FIELDS on ChapterType {
|
||||
...CHAPTER_BASE_FIELDS
|
||||
...CHAPTER_STATE_FIELDS
|
||||
|
||||
fetchedAt
|
||||
uploadDate
|
||||
}
|
||||
`;
|
||||
|
||||
export const CHAPTER_UPDATE_LIST_FIELDS = gql`
|
||||
${CHAPTER_LIST_FIELDS}
|
||||
${MANGA_BASE_FIELDS}
|
||||
|
||||
fragment CHAPTER_UPDATE_LIST_FIELDS on ChapterType {
|
||||
...CHAPTER_LIST_FIELDS
|
||||
|
||||
manga {
|
||||
...MANGA_BASE_FIELDS
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -1,7 +1,6 @@
|
||||
import {FieldPolicy, FieldReadFunction, Reference, TypePolicies, TypePolicy} from '@apollo/client/cache';
|
||||
import {
|
||||
GetChapterQueryVariables,
|
||||
GetChaptersQuery, GetDownloadStatusQueryVariables, GetExtensionQueryVariables, GetGlobalMetadataQueryVariables,
|
||||
GetChaptersMangaQuery, GetDownloadStatusQueryVariables, GetExtensionQueryVariables, GetGlobalMetadataQueryVariables,
|
||||
GetMangaQueryVariables, GetSourceQueryVariables, GetUpdateStatusQueryVariables, GetWebuiUpdateStatusQueryVariables,
|
||||
} from "@/lib/graphql/generated/graphql.ts";
|
||||
import {FieldFunctionOptions} from "@apollo/client/cache/inmemory/policies";
|
||||
@@ -575,8 +574,8 @@ export type QueryFieldPolicy = {
|
||||
aboutWebUI?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
categories?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
category?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
chapter?: FieldPolicy<Reference, Reference, Reference, FieldFunctionOptions<GetChapterQueryVariables>> | FieldReadFunction<Reference, Reference, FieldFunctionOptions<GetChapterQueryVariables>>,
|
||||
chapters?: FieldPolicy<GetChaptersQuery['chapters']> | FieldReadFunction<GetChaptersQuery['chapters']>,
|
||||
chapter?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
chapters?: FieldPolicy<GetChaptersMangaQuery['chapters']> | FieldReadFunction<GetChaptersMangaQuery['chapters']>,
|
||||
checkForServerUpdates?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
checkForWebUIUpdate?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
downloadStatus?: FieldPolicy<Reference, Reference, Reference, FieldFunctionOptions<GetDownloadStatusQueryVariables>> | FieldReadFunction<Reference, Reference, FieldFunctionOptions<GetDownloadStatusQueryVariables>>,
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -7,7 +7,8 @@
|
||||
*/
|
||||
|
||||
import gql from 'graphql-tag';
|
||||
import { BASE_TRACK_RECORD_FIELDS, FULL_CHAPTER_FIELDS } from '@/lib/graphql/Fragments';
|
||||
import { BASE_TRACK_RECORD_FIELDS } from '@/lib/graphql/Fragments';
|
||||
import { CHAPTER_LIST_FIELDS } from '@/lib/graphql/fragments/ChapterFragments.ts';
|
||||
|
||||
export const DELETE_CHAPTER_METADATA = gql`
|
||||
mutation DELETE_CHAPTER_METADATA($input: DeleteChapterMetaInput!) {
|
||||
@@ -51,12 +52,13 @@ export const GET_CHAPTER_PAGES_FETCH = gql`
|
||||
|
||||
// makes the server fetch and return the chapters of the manga
|
||||
export const GET_MANGA_CHAPTERS_FETCH = gql`
|
||||
${FULL_CHAPTER_FIELDS}
|
||||
${CHAPTER_LIST_FIELDS}
|
||||
|
||||
mutation GET_MANGA_CHAPTERS_FETCH($input: FetchChaptersInput!) {
|
||||
fetchChapters(input: $input) {
|
||||
clientMutationId
|
||||
chapters {
|
||||
...FULL_CHAPTER_FIELDS
|
||||
...CHAPTER_LIST_FIELDS
|
||||
manga {
|
||||
id
|
||||
chapters {
|
||||
|
||||
@@ -7,23 +7,20 @@
|
||||
*/
|
||||
|
||||
import gql from 'graphql-tag';
|
||||
import { FULL_CHAPTER_FIELDS, PAGE_INFO } from '@/lib/graphql/Fragments';
|
||||
|
||||
// returns the current chapter from the database
|
||||
export const GET_CHAPTER = gql`
|
||||
${FULL_CHAPTER_FIELDS}
|
||||
query GET_CHAPTER($id: Int!) {
|
||||
chapter(id: $id) {
|
||||
...FULL_CHAPTER_FIELDS
|
||||
}
|
||||
}
|
||||
`;
|
||||
import { PAGE_INFO } from '@/lib/graphql/Fragments';
|
||||
import {
|
||||
CHAPTER_LIST_FIELDS,
|
||||
CHAPTER_READER_FIELDS,
|
||||
CHAPTER_STATE_FIELDS,
|
||||
CHAPTER_UPDATE_LIST_FIELDS,
|
||||
} from '@/lib/graphql/fragments/ChapterFragments.ts';
|
||||
|
||||
// returns the current chapters from the database
|
||||
export const GET_CHAPTERS = gql`
|
||||
${FULL_CHAPTER_FIELDS}
|
||||
export const GET_CHAPTERS_READER = gql`
|
||||
${CHAPTER_READER_FIELDS}
|
||||
${PAGE_INFO}
|
||||
query GET_CHAPTERS(
|
||||
|
||||
query GET_CHAPTERS_READER(
|
||||
$after: Cursor
|
||||
$before: Cursor
|
||||
$condition: ChapterConditionInput
|
||||
@@ -46,7 +43,83 @@ export const GET_CHAPTERS = gql`
|
||||
orderByType: $orderByType
|
||||
) {
|
||||
nodes {
|
||||
...FULL_CHAPTER_FIELDS
|
||||
...CHAPTER_READER_FIELDS
|
||||
}
|
||||
pageInfo {
|
||||
...PAGE_INFO
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
// returns the current chapters from the database
|
||||
export const GET_CHAPTERS_MANGA = gql`
|
||||
${CHAPTER_LIST_FIELDS}
|
||||
${PAGE_INFO}
|
||||
|
||||
query GET_CHAPTERS_MANGA(
|
||||
$after: Cursor
|
||||
$before: Cursor
|
||||
$condition: ChapterConditionInput
|
||||
$filter: ChapterFilterInput
|
||||
$first: Int
|
||||
$last: Int
|
||||
$offset: Int
|
||||
$orderBy: ChapterOrderBy
|
||||
$orderByType: SortOrder
|
||||
) {
|
||||
chapters(
|
||||
after: $after
|
||||
before: $before
|
||||
condition: $condition
|
||||
filter: $filter
|
||||
first: $first
|
||||
last: $last
|
||||
offset: $offset
|
||||
orderBy: $orderBy
|
||||
orderByType: $orderByType
|
||||
) {
|
||||
nodes {
|
||||
...CHAPTER_LIST_FIELDS
|
||||
}
|
||||
pageInfo {
|
||||
...PAGE_INFO
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
// returns the current chapters from the database
|
||||
export const GET_CHAPTERS_UPDATES = gql`
|
||||
${CHAPTER_UPDATE_LIST_FIELDS}
|
||||
${PAGE_INFO}
|
||||
|
||||
query GET_CHAPTERS_UPDATES(
|
||||
$after: Cursor
|
||||
$before: Cursor
|
||||
$condition: ChapterConditionInput
|
||||
$filter: ChapterFilterInput
|
||||
$first: Int
|
||||
$last: Int
|
||||
$offset: Int
|
||||
$orderBy: ChapterOrderBy
|
||||
$orderByType: SortOrder
|
||||
) {
|
||||
chapters(
|
||||
after: $after
|
||||
before: $before
|
||||
condition: $condition
|
||||
filter: $filter
|
||||
first: $first
|
||||
last: $last
|
||||
offset: $offset
|
||||
orderBy: $orderBy
|
||||
orderByType: $orderByType
|
||||
) {
|
||||
nodes {
|
||||
...CHAPTER_UPDATE_LIST_FIELDS
|
||||
}
|
||||
pageInfo {
|
||||
...PAGE_INFO
|
||||
@@ -57,6 +130,8 @@ export const GET_CHAPTERS = gql`
|
||||
`;
|
||||
|
||||
export const GET_MANGAS_CHAPTER_IDS_WITH_STATE = gql`
|
||||
${CHAPTER_STATE_FIELDS}
|
||||
|
||||
query GET_MANGAS_CHAPTER_IDS_WITH_STATE(
|
||||
$mangaIds: [Int!]!
|
||||
$isDownloaded: Boolean = null
|
||||
@@ -69,10 +144,7 @@ export const GET_MANGAS_CHAPTER_IDS_WITH_STATE = gql`
|
||||
orderBy: SOURCE_ORDER
|
||||
) {
|
||||
nodes {
|
||||
id
|
||||
isDownloaded
|
||||
isRead
|
||||
isBookmarked
|
||||
...CHAPTER_STATE_FIELDS
|
||||
mangaId
|
||||
scanlator
|
||||
chapterNumber
|
||||
|
||||
Reference in New Issue
Block a user