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:
@@ -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: [] },
|
||||
|
||||
Reference in New Issue
Block a user