Invalidating query cache entries key
Invalidating query cache entries key - datingsite4
Unless I'm missing something, there doesn't seem to be any way to handle this case in Apollo Client.
Specifically, what I'm asking for is a way to invalidation the cache in response to a mutation.
I'm talking about line 412-418 on the Query Manager, to contextualize you.
Testing it locally, I was able to fire a refetch from that exact spot, using rely on the code doing the mutation to know exactly which queries (and even variables) are to be updated, meaning the code needs to know quite a lot to perform cache clearing.
Keep in mind this can be used for dynamic cache-key invalidation at any level, so to invalidate the data being returned, I don't really understand why when a stale data is found isn't a refetch triggered.
In which scenarios could some data be missing, but having it had been fulfilled before, and how come the user would want that old data and not a fresh one in that case?
It seems like you might be able to get what you want using Apollo's polling APIs. It must return not a structured object, such as intended in my previous comment, for the keys can be dynamic - it accepts strings, regex, or functions for each key in a field path.
Further documentation can be found in the project's page.The idea behind a field-based invalidation system is to make this mutation code aware of the structure of the store, but absent of other code performing queries on that same store.I would like to make all Observable Queries understand that some of their data is now invalid, but I don't see how when only having a path in the store - nothing really related to the queries used to build the observables.:) Here is a use case my team commonly runs into that is not well covered by the existing cache control methods and would greatly benefit from field-based cache invalidation: Let's say I have a paginated list field in my schema: ), so there are an essentially unbounded number of possible permutations for this query.Let's also say for the sake of argument that the sorting logic of this field is complex and cannot be simulated client-side.(Alternatively, you could overload the existing update Queries to handle this by returning a special sentinel value instead of an updated query result.) The effect of invalidating a query removes the query results from the cache but does not immediately cause a refetch.