Open wies105 opened 2 months ago
Update: I have updated my function to check if any qoue in the pipe and run into the same error
private deletedItemFromCache<T>(cache: any, classRef: T, id?: number) {
const singleRequest = getSingleRequestName(classRef);
const listRequest = getListRequestName(classRef);
this.apollo.client.getObservableQueries("active").forEach((observableQuery: any) => {
observableQuery.subscribe({
next: (result: any) => {
if (result.loading) {
console.log('Query is in flight:', observableQuery.queryId);
} else {
cache.modify({
id: "ROOT_QUERY",
fields: {
[listRequest](existingRefs: any, {readField}: {
readField: (fieldName: string, ref: any) => any
}) {
return existingRefs.items?.filter((ref: any) => id !== readField('id', ref)) || existingRefs.filter((ref: any) => id !== readField('id', ref));
},
[singleRequest](existingRefs: any, {readField}: {
readField: (fieldName: string, ref: any) => any
}) {
return existingRefs.items?.filter(
(ref : any) => id === readField('id', ref)
) || existingRefs.filter((ref: any) => id === readField('id', ref));
}
}
});
}
}
})
});
}
Hello, I get Store reset while query was in flight (not completed in link chain) after cache.evict called. I have an Angular 16 Project with "@apollo/client": "^3.11.0",
On Mutation, I will increase the cache.