0
Here is a scenario:
User A is friends with user B. User C is an admin. When user A queries the list of his friends, the list comes back, and user B is one of its members. This list is cached and the following queries are read from the cache. Now, let’s say the admin deleted this friendship from the database. How will graphql (urql’s graphCache in my case) know about this mutation and update user A’s cache to reflect the new state, which is that user B is no longer a friend?
My initial solution to this situation is to set the cache policy for this request to "network-only" fully bypassing the cache. However, the client will make unnecessary round trips that are only going to return new data when a mutation is executed by the admin C. Throughout all those page refreshes and rerenders of the components the query will be making completely unnecessary round trips.
How do I reconcile a clear need for caching and not return stale data from the cache?
1 Answer
Reset to default
0
In GraphQL, the client-side cache can be updated in reaction to data mutations triggered by a different user through a combination of subscription mechanisms and cache management techniques.