Invalidating Queries
Hey! Might be being thick here but I'm implementing in an optimistic update layer and fully expected this to work:
However that won't work. You can make it work by either removing the input - so
getWeek.queryKey() or by passing the key as the only arg;
Is there a way I can just invalidate the query based on input or am I thinking about this wrong?
The query key is correct as I can use setQueryData on it fine;
1 Reply
This should do exactly what you're asking if I'm understanding correctly. A query key generated with an input also uses the input for invalidation, you can console log it to see what we're creating and reference Tanstack's docs and dev tools to understand what matches will be made. By contrast you could use pathKey() to invalidate all queries regardless of input