Skip to content

exclude key in QueryFilters #3832

Answered by TkDodo
Sheraff asked this question in Ideas
Discussion options

You must be logged in to vote

calling invalidateQueries marks the query as invalid, but calling setQueryData actually marks it as valid again because you successfully give it data. With that in mind, what you can do is:

await queryClient.invalidateQueries(['endpoint'], { refetchType: 'none' }) // mark all 3 (or N) endpoints as stale, but don't refetch
queryClient.setQueryData(['endpoint', 'records'], () => /* some update logic */)
queryClient.invalidateQueries(['endpoint']) // now refetch all stale ones, which shouldn't contain the 'records'

Please note that refetchType is v4 syntax already, in v3, it would be refetchActive: false I think.

Granted, I'm not sure that this is a lot better, but it can handle the arbitra…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Sheraff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants