Imagine such a scenario: You have a products list which is retrieved through a query, and you can also filter the list which uses the same query just with a set filter parameter.
A subscription message arrives saying that there’s a new product available. Now how do I refetch all versions of that productsList query regardless of the variables? There could be like 2-3 versions of the field in the cache, all with different variables, and I want to refetch/evict all of them.
How do I achieve this?
Here’s another example: a User type with a “projects” field which can have different variables and I want to evict all variations:
Of course, that’s not the most elegant solution, particularly if you don’t have a simple way of accessing all previously-fetched permutations of a field with arguments. So you could consider evicting the entire User object as a simple but less efficient alternative. Another approach I’m far less certain about, so please do check my work here, is to use cache.modify:
cache.modify({
id: 'User:a7edfb464c',
fields: {
projects: (existing, details) {
// here's where you might be able to do what you're asking about
}
}
});
Again, I really can’t say whether this approach will get you there. It would definitely help to have a runnable reproduction here so I can test my assumptions. But hopefully that modifier function helps move you in a direction that could help narrow down a solution. The docs can help explain further if you haven’t used cache.modify before. Here’s the interface for the second parameter of a modify function, named details:
Hopefully INVALIDATE accomplishes what you need. Failing that, you may be able to get more surgical.
I hope that helps! If you get a moment, please do update the thread with any follow-up questions or (hopefully) the resolution