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•3y 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-goldOP•3y ago
i see, i probably need to start using
[{x, y, z}] thenfascinating-indigo•3y ago
I have a blogpost on that topic: https://tkdodo.eu/blog/leveraging-the-query-function-context#object-query-keys
Leveraging the Query Function Context
Use what React Query provides for optimal type safety