I have a filtered list of items based on a getAllItems
query, which takes a filter and an order by option as arguments.
After creating a new item, I want to delete the cache for this query, no matter what variables were passed. I don't know how to do this.
I don't think updating the cache is an option. Methods mentionned in Apollo Client documentation (Updating the cache after a mutation, refetchQueries and update) all seem to need a given set of variables, but since the filter is a complex object (with some text information), I would need to update the cache for every given set of variables that were previously submitted. I don't know how to do this. Plus, only the server does know how this new item impact pagination and ordering.
I don't think fetch-policy (for instance setting it to cache-and-network
) is what I'm looking for, because if accessing the network is what I want after having created a new item, when I'm just filtering the list (typing in a string to search), I want to stay with the default behavior (cache-only
).
client.resetStore
would reset the store for all type of queries (not only the getAllItems
query), so I don't think it's what I'm looking for either.
I'm pretty sure I'm missing something here.
getAllItems
query, would force all the search to come from the server – Harvcache.modfiy
in theupdate
option of the mutation, it will call your callback function for all argument variants it has cached for thegetAllItems
field, allowing you to remove the deleted item from any of them. – Vincentia