Define gql merge function for "trackRecords" field of "MangaType"

When opening the reader and going back to the library, the whole category of the previous opened manga gets refetched due to the readers manga query removing the mangas tracker data from the cache which is required in the library
This commit is contained in:
schroda
2024-09-08 01:52:36 +02:00
parent 4a742bb0ff
commit b57e5118cc

View File

@@ -24,6 +24,22 @@ import { StrictTypedTypePolicies } from '@/lib/graphql/generated/apollo-helpers.
/* eslint-disable no-underscore-dangle */
const typePolicies: StrictTypedTypePolicies = {
MangaType: {
fields: {
trackRecords: {
merge(existing, incoming) {
const nodes = incoming.nodes ?? existing?.nodes;
return {
...existing,
...incoming,
totalCount: nodes?.length ?? existing?.totalCount ?? incoming.totalCount,
nodes,
};
},
},
},
},
GlobalMetaType: { keyFields: ['key'] },
ExtensionType: { keyFields: ['pkgName'] },
AboutServerPayload: { keyFields: [] },