Invalidate query with new variables
Hello there, i have a problem with invalidating query.
Currently i have userQuery. Afterwards i have jobsQuery with variables from userQuery. It fetches good but when i update user using mutation and want to invalidate jobsQuery, it runs with the previous variables from user (not with the new ones). Is there any way i could pass the new variables to jobsQuery? When i do refetch manually it refetches with new variables.
Thank you for any ideas.
Here is example of my code:
2 Replies
sunny-green•3y ago
You probably need to invalidate the query that fetches the user or to use setQueryData to update the cache, so that
userQ.data will have the new values.
I also think that the dynamic terms in the jobs query should be in the query key.exotic-emeraldOP•3y ago
Yes i am invalidating the user query (its the “me” query). I need to invalidate this first and afterwards the jobs query. Will try the setQueryData and use dynamicTerms as query key.