Set exact=true as default in invalidateQueries() #3014
-
Hi, I do not understand why the QueryFilters-prop "exact" in invalidateQueries() does not have "true" as default. With the default "false" the option leads to more requests than necessary and sometimes also to unexpected behaviour. Alternatively, it would be OK for me if the option could be set globally via the QueryClientProvider. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
#1725 only wanted For invalidation, I think it all boils down to how you structure your query keys: https://tkdodo.eu/blog/effective-react-query-keys if you have:
and you only want
because that very explicitly allows me to either target everything todo related, or only the list (or lists, if I have multiple with filters), or a specific detail, without needing the exact option. |
Beta Was this translation helpful? Give feedback.
#1725 only wanted
exact
astrue
forgetQueryData
, which makes total sense. Otherwise, you might get a random entry (the first one that matches), which is not what is wanted.For invalidation, I think it all boils down to how you structure your query keys: https://tkdodo.eu/blog/effective-react-query-keys
if you have:
and you only want
todos
, you need to specify exact. Which is why I prefer:because that very explicitly allows me to either target everything todo related, or only the list (or lists, if I have multiple with filters), or a specific deta…