Reduce requested category data in queries
This commit is contained in:
42
src/lib/graphql/fragments/CategoryFragments.ts
Normal file
42
src/lib/graphql/fragments/CategoryFragments.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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';
|
||||
|
||||
export const CATEGORY_BASE_FIELDS = gql`
|
||||
fragment CATEGORY_BASE_FIELDS on CategoryType {
|
||||
id
|
||||
name
|
||||
|
||||
default
|
||||
order
|
||||
}
|
||||
`;
|
||||
|
||||
export const CATEGORY_LIBRARY_FIELDS = gql`
|
||||
${CATEGORY_BASE_FIELDS}
|
||||
|
||||
fragment CATEGORY_LIBRARY_FIELDS on CategoryType {
|
||||
...CATEGORY_BASE_FIELDS
|
||||
|
||||
mangas {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const CATEGORY_SETTING_FIELDS = gql`
|
||||
${CATEGORY_BASE_FIELDS}
|
||||
|
||||
fragment CATEGORY_SETTING_FIELDS on CategoryType {
|
||||
...CATEGORY_BASE_FIELDS
|
||||
|
||||
includeInUpdate
|
||||
includeInDownload
|
||||
}
|
||||
`;
|
||||
@@ -1,6 +1,6 @@
|
||||
import {FieldPolicy, FieldReadFunction, Reference, TypePolicies, TypePolicy} from '@apollo/client/cache';
|
||||
import {
|
||||
GetCategoryQueryVariables, GetChapterQueryVariables,
|
||||
GetChapterQueryVariables,
|
||||
GetChaptersQuery, GetDownloadStatusQueryVariables, GetExtensionQueryVariables, GetGlobalMetadataQueryVariables,
|
||||
GetMangaQueryVariables, GetSourceQueryVariables, GetUpdateStatusQueryVariables, GetWebuiUpdateStatusQueryVariables,
|
||||
} from "@/lib/graphql/generated/graphql.ts";
|
||||
@@ -574,7 +574,7 @@ export type QueryFieldPolicy = {
|
||||
aboutServer?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
aboutWebUI?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
categories?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
category?: FieldPolicy<Reference, Reference, Reference, FieldFunctionOptions<GetCategoryQueryVariables>> | FieldReadFunction<Reference, Reference, FieldFunctionOptions<GetCategoryQueryVariables>>,
|
||||
category?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
chapter?: FieldPolicy<Reference, Reference, Reference, FieldFunctionOptions<GetChapterQueryVariables>> | FieldReadFunction<Reference, Reference, FieldFunctionOptions<GetChapterQueryVariables>>,
|
||||
chapters?: FieldPolicy<GetChaptersQuery['chapters']> | FieldReadFunction<GetChaptersQuery['chapters']>,
|
||||
checkForServerUpdates?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
|
||||
@@ -2632,6 +2632,12 @@ export type WebuiUpdateStatusFragment = { __typename?: 'WebUIUpdateStatus', prog
|
||||
|
||||
export type ServerSettingsFragment = { __typename?: 'SettingsType', ip: string, port: number, socksProxyEnabled: boolean, socksProxyVersion: number, socksProxyHost: string, socksProxyPort: string, socksProxyUsername: string, socksProxyPassword: string, webUIFlavor: WebUiFlavor, initialOpenInBrowserEnabled: boolean, webUIInterface: WebUiInterface, electronPath: string, webUIChannel: WebUiChannel, webUIUpdateCheckInterval: number, downloadAsCbz: boolean, downloadsPath: string, autoDownloadNewChapters: boolean, excludeEntryWithUnreadChapters: boolean, autoDownloadNewChaptersLimit: number, autoDownloadIgnoreReUploads?: boolean | null, extensionRepos: Array<string>, maxSourcesInParallel: number, excludeUnreadChapters: boolean, excludeNotStarted: boolean, excludeCompleted: boolean, globalUpdateInterval: number, updateMangas: boolean, basicAuthEnabled: boolean, basicAuthUsername: string, basicAuthPassword: string, debugLogsEnabled: boolean, gqlDebugLogsEnabled: boolean, systemTrayEnabled: boolean, backupPath: string, backupTime: string, backupInterval: number, backupTTL: number, localSourcePath: string, flareSolverrEnabled: boolean, flareSolverrUrl: string, flareSolverrTimeout: number, flareSolverrSessionName: string, flareSolverrSessionTtl: number };
|
||||
|
||||
export type CategoryBaseFieldsFragment = { __typename?: 'CategoryType', id: number, name: string, default: boolean, order: number };
|
||||
|
||||
export type CategoryLibraryFieldsFragment = { __typename?: 'CategoryType', id: number, name: string, default: boolean, order: number, mangas: { __typename?: 'MangaNodeList', totalCount: number } };
|
||||
|
||||
export type CategorySettingFieldsFragment = { __typename?: 'CategoryType', includeInUpdate: IncludeOrExclude, includeInDownload: IncludeOrExclude, id: number, name: string, default: boolean, order: number };
|
||||
|
||||
export type CreateBackupMutationVariables = Exact<{
|
||||
input: CreateBackupInput;
|
||||
}>;
|
||||
@@ -2651,7 +2657,7 @@ export type CreateCategoryMutationVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type CreateCategoryMutation = { __typename?: 'Mutation', createCategory?: { __typename?: 'CreateCategoryPayload', clientMutationId?: string | null, category: { __typename?: 'CategoryType', default: boolean, id: number, includeInUpdate: IncludeOrExclude, includeInDownload: IncludeOrExclude, name: string, order: number, meta: Array<{ __typename?: 'CategoryMetaType', key: string, value: string }>, mangas: { __typename?: 'MangaNodeList', totalCount: number } } } | null };
|
||||
export type CreateCategoryMutation = { __typename?: 'Mutation', createCategory?: { __typename?: 'CreateCategoryPayload', clientMutationId?: string | null, category: { __typename?: 'CategoryType', includeInUpdate: IncludeOrExclude, includeInDownload: IncludeOrExclude, id: number, name: string, default: boolean, order: number } } | null };
|
||||
|
||||
export type DeleteCategoryMutationVariables = Exact<{
|
||||
input: DeleteCategoryInput;
|
||||
@@ -3074,7 +3080,7 @@ export type GetRestoreStatusQueryVariables = Exact<{
|
||||
|
||||
export type GetRestoreStatusQuery = { __typename?: 'Query', restoreStatus?: { __typename?: 'BackupRestoreStatus', mangaProgress: number, state: BackupRestoreState, totalManga: number } | null };
|
||||
|
||||
export type GetCategoriesQueryVariables = Exact<{
|
||||
export type GetCategoriesBaseQueryVariables = Exact<{
|
||||
after?: InputMaybe<Scalars['Cursor']['input']>;
|
||||
before?: InputMaybe<Scalars['Cursor']['input']>;
|
||||
condition?: InputMaybe<CategoryConditionInput>;
|
||||
@@ -3087,14 +3093,37 @@ export type GetCategoriesQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type GetCategoriesQuery = { __typename?: 'Query', categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', default: boolean, id: number, includeInUpdate: IncludeOrExclude, includeInDownload: IncludeOrExclude, name: string, order: number, meta: Array<{ __typename?: 'CategoryMetaType', key: string, value: string }>, mangas: { __typename?: 'MangaNodeList', totalCount: number } }>, pageInfo: { __typename?: 'PageInfo', endCursor?: string | null, hasNextPage: boolean, hasPreviousPage: boolean, startCursor?: string | null } } };
|
||||
export type GetCategoriesBaseQuery = { __typename?: 'Query', categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', id: number, name: string, default: boolean, order: number }>, pageInfo: { __typename?: 'PageInfo', endCursor?: string | null, hasNextPage: boolean, hasPreviousPage: boolean, startCursor?: string | null } } };
|
||||
|
||||
export type GetCategoryQueryVariables = Exact<{
|
||||
id: Scalars['Int']['input'];
|
||||
export type GetCategoriesLibraryQueryVariables = Exact<{
|
||||
after?: InputMaybe<Scalars['Cursor']['input']>;
|
||||
before?: InputMaybe<Scalars['Cursor']['input']>;
|
||||
condition?: InputMaybe<CategoryConditionInput>;
|
||||
filter?: InputMaybe<CategoryFilterInput>;
|
||||
first?: InputMaybe<Scalars['Int']['input']>;
|
||||
last?: InputMaybe<Scalars['Int']['input']>;
|
||||
offset?: InputMaybe<Scalars['Int']['input']>;
|
||||
orderBy?: InputMaybe<CategoryOrderBy>;
|
||||
orderByType?: InputMaybe<SortOrder>;
|
||||
}>;
|
||||
|
||||
|
||||
export type GetCategoryQuery = { __typename?: 'Query', category: { __typename?: 'CategoryType', default: boolean, id: number, includeInUpdate: IncludeOrExclude, includeInDownload: IncludeOrExclude, name: string, order: number, meta: Array<{ __typename?: 'CategoryMetaType', key: string, value: string }>, mangas: { __typename?: 'MangaNodeList', totalCount: number } } };
|
||||
export type GetCategoriesLibraryQuery = { __typename?: 'Query', categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', id: number, name: string, default: boolean, order: number, mangas: { __typename?: 'MangaNodeList', totalCount: number } }>, pageInfo: { __typename?: 'PageInfo', endCursor?: string | null, hasNextPage: boolean, hasPreviousPage: boolean, startCursor?: string | null } } };
|
||||
|
||||
export type GetCategoriesSettingsQueryVariables = Exact<{
|
||||
after?: InputMaybe<Scalars['Cursor']['input']>;
|
||||
before?: InputMaybe<Scalars['Cursor']['input']>;
|
||||
condition?: InputMaybe<CategoryConditionInput>;
|
||||
filter?: InputMaybe<CategoryFilterInput>;
|
||||
first?: InputMaybe<Scalars['Int']['input']>;
|
||||
last?: InputMaybe<Scalars['Int']['input']>;
|
||||
offset?: InputMaybe<Scalars['Int']['input']>;
|
||||
orderBy?: InputMaybe<CategoryOrderBy>;
|
||||
orderByType?: InputMaybe<SortOrder>;
|
||||
}>;
|
||||
|
||||
|
||||
export type GetCategoriesSettingsQuery = { __typename?: 'Query', categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', includeInUpdate: IncludeOrExclude, includeInDownload: IncludeOrExclude, id: number, name: string, default: boolean, order: number }>, pageInfo: { __typename?: 'PageInfo', endCursor?: string | null, hasNextPage: boolean, hasPreviousPage: boolean, startCursor?: string | null } } };
|
||||
|
||||
export type GetCategoryMangasQueryVariables = Exact<{
|
||||
id: Scalars['Int']['input'];
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
*/
|
||||
|
||||
import gql from 'graphql-tag';
|
||||
import { FULL_CATEGORY_FIELDS } from '@/lib/graphql/Fragments';
|
||||
import { CATEGORY_SETTING_FIELDS } from '@/lib/graphql/fragments/CategoryFragments.ts';
|
||||
|
||||
export const CREATE_CATEGORY = gql`
|
||||
${FULL_CATEGORY_FIELDS}
|
||||
${CATEGORY_SETTING_FIELDS}
|
||||
mutation CREATE_CATEGORY($input: CreateCategoryInput!) {
|
||||
createCategory(input: $input) {
|
||||
clientMutationId
|
||||
category {
|
||||
...FULL_CATEGORY_FIELDS
|
||||
...CATEGORY_SETTING_FIELDS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,18 @@
|
||||
*/
|
||||
|
||||
import gql from 'graphql-tag';
|
||||
import { FULL_CATEGORY_FIELDS, FULL_MANGA_FIELDS, PAGE_INFO } from '@/lib/graphql/Fragments';
|
||||
import { FULL_MANGA_FIELDS, PAGE_INFO } from '@/lib/graphql/Fragments';
|
||||
import {
|
||||
CATEGORY_BASE_FIELDS,
|
||||
CATEGORY_LIBRARY_FIELDS,
|
||||
CATEGORY_SETTING_FIELDS,
|
||||
} from '@/lib/graphql/fragments/CategoryFragments.ts';
|
||||
|
||||
export const GET_CATEGORIES = gql`
|
||||
${FULL_CATEGORY_FIELDS}
|
||||
export const GET_CATEGORIES_BASE = gql`
|
||||
${CATEGORY_BASE_FIELDS}
|
||||
${PAGE_INFO}
|
||||
query GET_CATEGORIES(
|
||||
|
||||
query GET_CATEGORIES_BASE(
|
||||
$after: Cursor
|
||||
$before: Cursor
|
||||
$condition: CategoryConditionInput
|
||||
@@ -35,7 +41,7 @@ export const GET_CATEGORIES = gql`
|
||||
orderByType: $orderByType
|
||||
) {
|
||||
nodes {
|
||||
...FULL_CATEGORY_FIELDS
|
||||
...CATEGORY_BASE_FIELDS
|
||||
}
|
||||
pageInfo {
|
||||
...PAGE_INFO
|
||||
@@ -45,11 +51,76 @@ export const GET_CATEGORIES = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const GET_CATEGORY = gql`
|
||||
${FULL_CATEGORY_FIELDS}
|
||||
query GET_CATEGORY($id: Int!) {
|
||||
category(id: $id) {
|
||||
...FULL_CATEGORY_FIELDS
|
||||
export const GET_CATEGORIES_LIBRARY = gql`
|
||||
${CATEGORY_LIBRARY_FIELDS}
|
||||
${PAGE_INFO}
|
||||
|
||||
query GET_CATEGORIES_LIBRARY(
|
||||
$after: Cursor
|
||||
$before: Cursor
|
||||
$condition: CategoryConditionInput
|
||||
$filter: CategoryFilterInput
|
||||
$first: Int
|
||||
$last: Int
|
||||
$offset: Int
|
||||
$orderBy: CategoryOrderBy
|
||||
$orderByType: SortOrder
|
||||
) {
|
||||
categories(
|
||||
after: $after
|
||||
before: $before
|
||||
condition: $condition
|
||||
filter: $filter
|
||||
first: $first
|
||||
last: $last
|
||||
offset: $offset
|
||||
orderBy: $orderBy
|
||||
orderByType: $orderByType
|
||||
) {
|
||||
nodes {
|
||||
...CATEGORY_LIBRARY_FIELDS
|
||||
}
|
||||
pageInfo {
|
||||
...PAGE_INFO
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const GET_CATEGORIES_SETTINGS = gql`
|
||||
${CATEGORY_SETTING_FIELDS}
|
||||
${PAGE_INFO}
|
||||
|
||||
query GET_CATEGORIES_SETTINGS(
|
||||
$after: Cursor
|
||||
$before: Cursor
|
||||
$condition: CategoryConditionInput
|
||||
$filter: CategoryFilterInput
|
||||
$first: Int
|
||||
$last: Int
|
||||
$offset: Int
|
||||
$orderBy: CategoryOrderBy
|
||||
$orderByType: SortOrder
|
||||
) {
|
||||
categories(
|
||||
after: $after
|
||||
before: $before
|
||||
condition: $condition
|
||||
filter: $filter
|
||||
first: $first
|
||||
last: $last
|
||||
offset: $offset
|
||||
orderBy: $orderBy
|
||||
orderByType: $orderByType
|
||||
) {
|
||||
nodes {
|
||||
...CATEGORY_SETTING_FIELDS
|
||||
}
|
||||
pageInfo {
|
||||
...PAGE_INFO
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user