Update apollo cache eviction

This commit is contained in:
schroda
2026-06-21 18:37:45 +02:00
parent 4f4ca98290
commit f145485949

View File

@@ -2283,8 +2283,12 @@ export class RequestManager {
const wrappedMutate = (mutateOptions: Parameters<typeof mutate>[0]) => const wrappedMutate = (mutateOptions: Parameters<typeof mutate>[0]) =>
mutate({ mutate({
onCompleted: () => { onCompleted: () => {
this.graphQLClient.client.cache.evict({ broadcast: true, fieldName: 'categories' }); this.graphQLClient.client.refetchQueries({
this.graphQLClient.client.cache.evict({ broadcast: true, fieldName: 'mangas' }); updateCache(cache) {
cache.evict({ fieldName: 'categories' });
cache.evict({ fieldName: 'mangas' });
},
});
}, },
...mutateOptions, ...mutateOptions,
}); });
@@ -2305,8 +2309,12 @@ export class RequestManager {
); );
response.response.then(() => { response.response.then(() => {
this.graphQLClient.client.cache.evict({ broadcast: true, fieldName: 'categories' }); this.graphQLClient.client.refetchQueries({
this.graphQLClient.client.cache.evict({ broadcast: true, fieldName: 'mangas' }); updateCache(cache) {
cache.evict({ fieldName: 'categories' });
cache.evict({ fieldName: 'mangas' });
},
});
}); });
return response; return response;
@@ -2329,8 +2337,13 @@ export class RequestManager {
); );
result.response.then(() => { result.response.then(() => {
this.graphQLClient.client.cache.evict({ broadcast: true, fieldName: 'categories' }); this.graphQLClient.client.refetchQueries({
this.graphQLClient.client.cache.evict({ broadcast: true, fieldName: 'mangas' }); updateCache(cache) {
cache.evict({ fieldName: 'categories' });
cache.evict({ fieldName: 'category' });
cache.evict({ fieldName: 'mangas' });
},
});
}); });
return result; return result;
@@ -2353,9 +2366,13 @@ export class RequestManager {
); );
result.response.then(() => { result.response.then(() => {
this.graphQLClient.client.cache.evict({ fieldName: 'categories' }); this.graphQLClient.client.refetchQueries({
this.graphQLClient.client.cache.evict({ fieldName: 'category' }); updateCache(cache) {
this.graphQLClient.client.cache.evict({ fieldName: 'mangas' }); cache.evict({ fieldName: 'categories' });
cache.evict({ fieldName: 'category' });
cache.evict({ fieldName: 'mangas' });
},
});
}); });
return result; return result;
@@ -2963,14 +2980,15 @@ export class RequestManager {
GQLMethod.MUTATION, GQLMethod.MUTATION,
DELETE_CATEGORY, DELETE_CATEGORY,
{ input: { categoryId } }, { input: { categoryId } },
{ options,
refetchQueries: [GET_CATEGORIES_BASE, GET_CATEGORIES_LIBRARY, GET_CATEGORIES_SETTINGS],
...options,
},
); );
result.response.then(() => { result.response.then(() => {
this.graphQLClient.client.cache.evict({ fieldName: 'category', id: categoryId.toString() }); this.graphQLClient.client.refetchQueries({
updateCache(cache) {
cache.evict({ id: cache.identify({ __typename: 'CategoryType', id: categoryId.toString() }) });
},
});
}); });
return result; return result;
@@ -3441,9 +3459,12 @@ export class RequestManager {
const { cache } = this.graphQLClient.client; const { cache } = this.graphQLClient.client;
if (downloadChanged?.omittedUpdates) { if (downloadChanged?.omittedUpdates) {
cache.gc(); this.graphQLClient.client.refetchQueries({
cache.evict({ broadcast: true, id: 'DownloadStatus:{}' }); updateCache() {
cache.evict({ broadcast: true, fieldName: 'downloadStatus' }); cache.evict({ id: 'DownloadStatus:{}' });
cache.evict({ fieldName: 'downloadStatus' });
},
});
return; return;
} }
@@ -3551,9 +3572,12 @@ export class RequestManager {
return; return;
} }
cache.gc(); this.graphQLClient.client.refetchQueries({
cache.evict({ broadcast: true, id: 'LibraryUpdateStatus' }); updateCache() {
cache.evict({ broadcast: true, fieldName: 'libraryUpdateStatus' }); cache.evict({ fieldName: 'chapters' });
cache.evict({ fieldName: 'libraryUpdateStatus' });
},
});
}, },
} as SubscriptionHookOptions<UpdaterSubscription, UpdaterSubscriptionVariables>, } as SubscriptionHookOptions<UpdaterSubscription, UpdaterSubscriptionVariables>,
) as useSubscription.Result<UpdaterSubscription>; ) as useSubscription.Result<UpdaterSubscription>;