Fix refetching categories after library database cleanup
GET_CATEGORIES_LIBRARY, GET_CATEGORIES_SETTINGS share the same query key in the cache. However, both select different fields. When cleaning up the database in the library settings, the SETTINGS query is active and refetches due to the cache eviction. This then wrote the query back into the cache pointing to the existing CategoryType fragments in the cache. The problem was that the SETTINGS query selects fewer fields than the LIBRARY query. Due to the query now existing again in the cache, the LIBRARY query was not refetched. Instead, it used the cached category fragments, which still included the outdated LIBRARY fields from before the eviction
This commit is contained in:
@@ -2393,6 +2393,14 @@ export class RequestManager {
|
||||
onCompleted: () => {
|
||||
this.graphQLClient.client.refetchQueries({
|
||||
updateCache(cache) {
|
||||
const data = (cache as InMemoryCache).extract();
|
||||
|
||||
for (const [id, value] of Object.entries(data)) {
|
||||
if ((value as any).__typename === 'CategoryType') {
|
||||
cache.evict({ id });
|
||||
}
|
||||
}
|
||||
|
||||
cache.evict({ fieldName: 'categories' });
|
||||
cache.evict({ fieldName: 'mangas' });
|
||||
},
|
||||
@@ -2419,6 +2427,14 @@ export class RequestManager {
|
||||
response.response.then(() => {
|
||||
this.graphQLClient.client.refetchQueries({
|
||||
updateCache(cache) {
|
||||
const data = (cache as InMemoryCache).extract();
|
||||
|
||||
for (const [id, value] of Object.entries(data)) {
|
||||
if ((value as any).__typename === 'CategoryType') {
|
||||
cache.evict({ id });
|
||||
}
|
||||
}
|
||||
|
||||
cache.evict({ fieldName: 'categories' });
|
||||
cache.evict({ fieldName: 'mangas' });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user