Is there a way to invalidate specific cache entries using the document cache? #1425
-
My setup is currently the following:
However, there are sometimes issues when querying data from the server; when this happens, we have an error boundary set up which shows a window explaining that something went wrong. What I'd like to do is to be able to invalidate a specific document in the document cache for the query that is being executed in the appropriate section. I'd prefer not to invalidate the entire client if possible (but I believe I can if necessary). I believe I can do this with the normalized cache, but that's a much larger lift which I'm trying to avoid. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Hey, Both of our caches are reliant on the semantics of GraphQL which means that a mutation result (or a subscription trigger - normalized cache) are the best ways to invalidate data. If your For instance if The behavior you're describing makes me think you're looking for some |
Beta Was this translation helpful? Give feedback.
Hey,
Both of our caches are reliant on the semantics of GraphQL which means that a mutation result (or a subscription trigger - normalized cache) are the best ways to invalidate data. If your
ErrorBoundary
is some form of mutation you could attach this to theoptions.context
value.For instance if
useQuery.todos
fails that has__typename=Todo
we could do something likereportError(x, { context: { additionalTypenames: ['Todo'] } }
which will invalidate all queries that have aTodo
in the results.The behavior you're describing makes me think you're looking for some
revalidate
pattern, your queries were a success but as the result of an ErrorBoundary that goes away you want to refetch them,…