Using Apollo Client 3 and eed to remove all the results of a query regardless of the arguments. Tried like this;
cache.evict({
id: "ROOT_QUERY",
fieldName: "countries"
});
cache.gc();
However nothing removed from cache, __APOLLO_CLIENT__.cache.data
still has all the result in the cache.
I can remove a single Country object on the other hand.
You can see it here sandbox
console.log("cache", cache.data.data);
), -gc()
doesn't matter ... but problem is with hooks, view isn't rerendered when 'data' is cleared ... IMHO it's an apollo issue as change is propagated (this.broadcastWatches();
called), 'data' should be set to undefined again .... workaround? writeQuery with ampty data? – WellgroomeduseLazyQuery
andcache.evict({ id: "ROOT_QUERY", fieldName: "countries" });
After this cache.evict, apollo client somehow can not reconcile query and the cache, so it queries again. Do you think that we can use this sameuseLazyQuery
hook in out page with different fetch policies to overcome this? – Klimt