objects matching behaviour
Say I have the following query keys:
and say I do this
note I didn't pass an Id, so the generated key would be
['todos', {}].
Would that match all my subsequent keys, with ids defined, or not? 🤔4 Replies
other-emerald•3y ago
This should work. Otherwise you should've passed
exact: true . See
- https://tanstack.com/query/latest/docs/react/guides/query-invalidation
- https://tanstack.com/query/v4/docs/react/reference/QueryClient#queryclientrefetchqueriesold-apricotOP•3y ago
where is it stated in the docs that this is how it works?
other-emerald•3y ago
The invalidateQueries API is very flexible, so even if you want to only invalidate todos queries that don't have any more variables or subkeys, you can pass an exact: true option to the invalidateQueries method:
old-apricotOP•3y ago
I see
so it would only try to match variables I provided, and if I didn't it'll pass
thanks