Reduce requested category data in queries
This commit is contained in:
@@ -6,15 +6,15 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { TCategory } from '@/typings.ts';
|
||||
import { CategoryType } from '@/lib/graphql/generated/graphql.ts';
|
||||
|
||||
export const DEFAULT_CATEGORY_ID = 0;
|
||||
|
||||
export type CategoryIdInfo = Pick<TCategory, 'id'>;
|
||||
export type CategoryNameInfo = Pick<TCategory, 'name'>;
|
||||
export type CategoryDefaultInfo = Pick<TCategory, 'default'>;
|
||||
export type CategoryUpdateInclusionInfo = Pick<TCategory, 'includeInUpdate'>;
|
||||
export type CategoryDownloadInclusionInfo = Pick<TCategory, 'includeInDownload'>;
|
||||
export type CategoryIdInfo = Pick<CategoryType, 'id'>;
|
||||
export type CategoryNameInfo = Pick<CategoryType, 'name'>;
|
||||
export type CategoryDefaultInfo = Pick<CategoryType, 'default'>;
|
||||
export type CategoryUpdateInclusionInfo = Pick<CategoryType, 'includeInUpdate'>;
|
||||
export type CategoryDownloadInclusionInfo = Pick<CategoryType, 'includeInDownload'>;
|
||||
|
||||
export class Categories {
|
||||
static getIds(categories: CategoryIdInfo[]): number[] {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
Metadata,
|
||||
MetadataHolder,
|
||||
MetadataKeyValuePair,
|
||||
TCategory,
|
||||
TChapter,
|
||||
TManga,
|
||||
TPartialSource,
|
||||
@@ -22,6 +21,7 @@ import {
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { MetaType } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { DEFAULT_DEVICE, getActiveDevice } from '@/util/device.ts';
|
||||
import { CategoryIdInfo } from '@/lib/data/Categories.ts';
|
||||
|
||||
const APP_METADATA_KEY_PREFIX = 'webUI_';
|
||||
|
||||
@@ -370,7 +370,7 @@ export const requestUpdateMetadataValue = async (
|
||||
|
||||
switch (holderType) {
|
||||
case 'category':
|
||||
await requestManager.setCategoryMeta((metadataHolder as TCategory).id, metadataKey, value).response;
|
||||
await requestManager.setCategoryMeta((metadataHolder as CategoryIdInfo).id, metadataKey, value).response;
|
||||
break;
|
||||
case 'chapter':
|
||||
await requestManager.setChapterMeta((metadataHolder as TChapter).id, metadataKey, value).response;
|
||||
@@ -410,7 +410,7 @@ export const requestUpdateChapterMetadata = async (
|
||||
): Promise<void[]> => requestUpdateMetadata(chapter, 'chapter', keysToValues);
|
||||
|
||||
export const requestUpdateCategoryMetadata = async (
|
||||
category: TCategory,
|
||||
category: CategoryIdInfo & GqlMetaHolder,
|
||||
keysToValues: MetadataKeyValuePair[],
|
||||
): Promise<void[]> => requestUpdateMetadata(category, 'category', keysToValues);
|
||||
|
||||
|
||||
@@ -65,8 +65,6 @@ import {
|
||||
FilterChangeInput,
|
||||
GetAboutQuery,
|
||||
GetAboutQueryVariables,
|
||||
GetCategoriesQuery,
|
||||
GetCategoriesQueryVariables,
|
||||
GetCategoryMangasQuery,
|
||||
GetCategoryMangasQueryVariables,
|
||||
GetChapterPagesFetchMutation,
|
||||
@@ -199,6 +197,8 @@ import {
|
||||
GetServerSettingsQueryVariables,
|
||||
SetSourceMetadataMutation,
|
||||
SetSourceMetadataMutationVariables,
|
||||
GetCategoriesSettingsQuery,
|
||||
GetCategoriesSettingsQueryVariables,
|
||||
} from '@/lib/graphql/generated/graphql.ts';
|
||||
import { GET_GLOBAL_METADATAS } from '@/lib/graphql/queries/GlobalMetadataQuery.ts';
|
||||
import { SET_GLOBAL_METADATA } from '@/lib/graphql/mutations/GlobalMetadataMutation.ts';
|
||||
@@ -230,7 +230,12 @@ import {
|
||||
GET_MANGAS,
|
||||
GET_MIGRATABLE_SOURCE_MANGAS,
|
||||
} from '@/lib/graphql/queries/MangaQuery.ts';
|
||||
import { GET_CATEGORIES, GET_CATEGORY_MANGAS } from '@/lib/graphql/queries/CategoryQuery.ts';
|
||||
import {
|
||||
GET_CATEGORIES_BASE,
|
||||
GET_CATEGORIES_LIBRARY,
|
||||
GET_CATEGORIES_SETTINGS,
|
||||
GET_CATEGORY_MANGAS,
|
||||
} from '@/lib/graphql/queries/CategoryQuery.ts';
|
||||
import {
|
||||
GET_SOURCE_MANGAS_FETCH,
|
||||
SET_SOURCE_METADATA,
|
||||
@@ -2063,28 +2068,30 @@ export class RequestManager {
|
||||
);
|
||||
}
|
||||
|
||||
public useGetCategories(
|
||||
options?: QueryHookOptions<GetCategoriesQuery, GetCategoriesQueryVariables>,
|
||||
): AbortableApolloUseQueryResponse<GetCategoriesQuery, GetCategoriesQueryVariables> {
|
||||
return this.doRequest<GetCategoriesQuery, GetCategoriesQueryVariables>(
|
||||
public useGetCategories<Data, Variables extends OperationVariables>(
|
||||
document: DocumentNode | TypedDocumentNode<Data, Variables>,
|
||||
options?: QueryHookOptions<Data, Variables>,
|
||||
): AbortableApolloUseQueryResponse<Data, Variables> {
|
||||
return this.doRequest<Data, Variables>(
|
||||
GQLMethod.USE_QUERY,
|
||||
GET_CATEGORIES,
|
||||
document,
|
||||
{
|
||||
orderBy: CategoryOrderBy.Order,
|
||||
},
|
||||
} as unknown as Variables,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
public getCategories(
|
||||
options?: QueryOptions<GetCategoriesQueryVariables, GetCategoriesQuery>,
|
||||
): AbortabaleApolloQueryResponse<GetCategoriesQuery> {
|
||||
return this.doRequest(
|
||||
public getCategories<Data, Variables extends OperationVariables>(
|
||||
document: DocumentNode | TypedDocumentNode<Data, Variables>,
|
||||
options?: QueryOptions<Variables, Data>,
|
||||
): AbortabaleApolloQueryResponse<Data> {
|
||||
return this.doRequest<Data, Variables>(
|
||||
GQLMethod.QUERY,
|
||||
GET_CATEGORIES,
|
||||
document,
|
||||
{
|
||||
orderBy: CategoryOrderBy.Order,
|
||||
},
|
||||
} as unknown as Variables,
|
||||
options,
|
||||
);
|
||||
}
|
||||
@@ -2097,7 +2104,7 @@ export class RequestManager {
|
||||
GQLMethod.MUTATION,
|
||||
CREATE_CATEGORY,
|
||||
{ input },
|
||||
{ refetchQueries: [GET_CATEGORIES], ...options },
|
||||
{ refetchQueries: [GET_CATEGORIES_BASE, GET_CATEGORIES_LIBRARY, GET_CATEGORIES_SETTINGS], ...options },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2108,16 +2115,16 @@ export class RequestManager {
|
||||
GQLMethod.USE_MUTATION,
|
||||
UPDATE_CATEGORY_ORDER,
|
||||
undefined,
|
||||
options,
|
||||
{ refetchQueries: [GET_CATEGORIES_BASE, GET_CATEGORIES_LIBRARY], ...options },
|
||||
);
|
||||
|
||||
const wrappedMutate = (mutateOptions: Parameters<typeof mutate>[0]) => {
|
||||
const variables = mutateOptions?.variables?.input;
|
||||
const cachedCategories = this.graphQLClient.client.readQuery<
|
||||
GetCategoriesQuery,
|
||||
GetCategoriesQueryVariables
|
||||
GetCategoriesSettingsQuery,
|
||||
GetCategoriesSettingsQueryVariables
|
||||
>({
|
||||
query: GET_CATEGORIES,
|
||||
query: GET_CATEGORIES_SETTINGS,
|
||||
variables: { orderBy: CategoryOrderBy.Order },
|
||||
})?.categories.nodes;
|
||||
|
||||
@@ -2138,10 +2145,10 @@ export class RequestManager {
|
||||
|
||||
return mutate({
|
||||
update: (cache) => {
|
||||
cache.updateQuery<GetCategoriesQuery, GetCategoriesQueryVariables>(
|
||||
cache.updateQuery<GetCategoriesSettingsQuery, GetCategoriesSettingsQueryVariables>(
|
||||
{
|
||||
id: cache.identify({ __typename: 'CategoryNodeList' }),
|
||||
query: GET_CATEGORIES,
|
||||
query: GET_CATEGORIES_SETTINGS,
|
||||
variables: { orderBy: CategoryOrderBy.Order },
|
||||
},
|
||||
(data) => ({
|
||||
@@ -2205,7 +2212,7 @@ export class RequestManager {
|
||||
DELETE_CATEGORY,
|
||||
{ input: { categoryId } },
|
||||
{
|
||||
refetchQueries: [GET_CATEGORIES],
|
||||
refetchQueries: [GET_CATEGORIES_BASE, GET_CATEGORIES_LIBRARY, GET_CATEGORIES_SETTINGS],
|
||||
...options,
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user