TanStackT
TanStack17mo ago
5 replies
moderate-tomato

Refetch all data vs filtered data

I have a click action that filters my list of ingredients like this:
queryClient.setQueryData(
        ['CCCIngredients', selectedCostCenter?.value],
        (oldData: Ingredient[] | undefined) => {
            return (
                oldData?.filter((i) =>
                    allowedIngredients.some(...

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:
queryClient.setQueryData(
    ['CCCIngredients', selectedCostCenter?.value],
    (oldData: Ingredient[] | undefined) => {
        console.log({oldData});
        return oldData
    });

But this just gets the same filtered data.
Was this page helpful?