Skip to content

Is there a way to invalidate specific cache entries using the document cache? #1425

Answered by JoviDeCroock
casperOne asked this question in Q&A
Discussion options

You must be logged in to vote

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 the options.context value.

For instance if useQuery.todos fails that has __typename=Todo we could do something like reportError(x, { context: { additionalTypenames: ['Todo'] } } which will invalidate all queries that have a Todo 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,…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@JoviDeCroock
Comment options

@casperOne
Comment options

@casperOne
Comment options

@kitten
Comment options

@casperOne
Comment options

Answer selected by kitten
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants