T
TanStack3y ago
optimistic-gold

Query invalidation -- how to invalidate [x, y, z]

I have queryKey [x,y,z] and I want to invalidate y such that [x,y,z] gets invalidated. Will queryClient.invalidateQueries([y]) do this? What will?
3 Replies
fascinating-indigo
fascinating-indigo3y ago
[x, y] will because arrays have an order and array keys form a hierarchy If the key is [{ x, y, z }], it can be targeted with [{ y }] because objects have no order.
optimistic-gold
optimistic-goldOP3y ago
i see, i probably need to start using [{x, y, z}] then
fascinating-indigo
fascinating-indigo3y ago
Leveraging the Query Function Context
Use what React Query provides for optimal type safety

Did you find this page helpful?