Skip to content
Discussion options

You must be logged in to vote

You could:

  • invalidate all queries that relate to the mutation:
queryClient.invalidateQueries(["todos"])
queryClient.invalidateQueries(["todo", selected])

this can even be done with one statement if you use the smart matching, but they would all have to start with the same key (e.g. todos and todos, selected:

queryClient.invalidateQueries(["todos"])
  • you can manually manipulate the query cache instead of invalidating, preferably in the onMutate function, and then rollback on error / invalidate on success. see the optimistic update example in the docs.

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@fnn
Comment options

@TkDodo
Comment options

@fnn
Comment options

@fnn
Comment options

Answer selected by fnn
Comment options

You must be logged in to vote
1 reply
@fnn
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants