You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's an issue I'm facing using queryClient functions to either invalidate or refetch multiple queries.
According to the docs, Invalidating multiple queries should be done using this syntax:
queryClient.invalidateQueries(['query1', 'query2']):
Result-wise: This works; it refetches the queries, but I get a Typescript error: Type 'EQueryKeys[][]' has no properties in common with type 'RefetchQueryFilters<any, any, any, any>'.ts(2559)
When I try to correct it into what TS wants which is this syntax:
queryClient.invalidateQueries({
queryKey: ['query1', 'query2']
})
This removes the TS Error, but result-wise: it doesn't invalidate the query.
Pls can this be looked into, or am I the one doing something wrong?
queryClient.invalidateQueries({ queryKey: ['query1', 'query2'] }) will not invalidate query1 and query2 but queries matching query key ['query1', 'query2']. This probably does not match any of your queries, since I assume their query keys are ['query1'] and ['query2'] (always an array). You probably need:
Describe the bug
There's an issue I'm facing using queryClient functions to either invalidate or refetch multiple queries.
According to the docs, Invalidating multiple queries should be done using this syntax:
queryClient.invalidateQueries(['query1', 'query2']):
Result-wise: This works; it refetches the queries, but I get a Typescript error:
Type 'EQueryKeys[][]' has no properties in common with type 'RefetchQueryFilters<any, any, any, any>'.ts(2559)
When I try to correct it into what TS wants which is this syntax:
queryClient.invalidateQueries({
queryKey: ['query1', 'query2']
})
This removes the TS Error, but result-wise: it doesn't invalidate the query.
Pls can this be looked into, or am I the one doing something wrong?
Your minimal, reproducible example
https://codesandbox.io/p/devbox/polished-frog-8vsv92
Steps to reproduce
Try to refetch multiple queiries using
queryClient.refetchQueries(['query1', 'query2']):
Expected behavior
It should refetch the queries, but I'll get a TS error on my IDE
How often does this bug happen?
Every time
Screenshots or Videos
Platform
Tanstack Query adapter
react-query
TanStack Query version
v5.64.1
TypeScript version
v5
Additional context
No response
The text was updated successfully, but these errors were encountered: