When I fire this mutation, there is really no telling where it will be inserted into the list, given the aforementioned complex sorting logic.
The only logical update I can make to the state of the store is to flag either the as invalid and needing a refetch, or to invalidate every instance of the query, regardless of what its variables are.
That's why I suggest that the new feature be part of the mutation API since it's very similar in concept to the existing update Queries feature.
Your second use case has to do with invalidating the cache after a time interval and is unrelated to mutations.
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.
It should be just marked as stale so in case user will open such page again query will will be executed.
@lucasconstantino yeah seems active observable queries making problems in such case. It gives you direct access to the cache, so you can accomplish quite everything you would need.
Unless I'm missing something, there doesn't seem to be any way to handle this case in Apollo Client.
right after mutation because there could be a lot of such queries and maybe user will not go again to pages that are using them.
However, I don't want to force an immediate refetch because it may be a while before I actually need the results of the query.