Refetch all data vs filtered data
I have a click action that filters my list of ingredients like this:
Now, I want to reverse that action on a different click action. So I want to go get all the ingredients again.
I tried doing this:
But this just gets the same filtered data.
5 Replies
genetic-orangeOP•13mo ago
OK, so I figured out this does work:
await queryClient.invalidateQueries({queryKey: ['CCCIngredients', selectedCostCenter?.value]});
Is that the wrong way to do things or is that acceptable?exotic-emerald•13mo ago
I wouldn't update the cache I would just use
select
genetic-orangeOP•13mo ago
So are you saying change my
select
data in each of the two scenarios?exotic-emerald•13mo ago
I'm not sure I understand what you're asking. Using
select
from useQuery
allows you to filter/transform/etc the data in the cache so you can filter the data without destroying the cache and forcing a refetch.
genetic-orangeOP•13mo ago
oh that makes sense and as allowedIngredients gets updated, that list will update