-
|
Hi there, I've been reading up on the docs and trying to find other people with my issues, but I can't figure out how to do this... I either end up with no caching at all or just not able to invalidate it. The scenario is that I call my graphql endpoint with dynamically generated queries, i never know what are the contents of these, at mas i know which is a mutation or which is a normal query. But i can't know the names of the internal values. From what i see in the docs, i can only invalidate cache with these exchanges (types don't work if I try to use the graphcache btw) but i need to specify the query key i want to drop the cache for... in my case i would like to just drop ALL cache one i do a mutation. I also tried calling I have a recoil atom where i store the client So then i created a hook where i reset this state by recreating the client, but the cache doesn't seem to go away: I gues that the ideal would be to be able to pass part of the dynamically generated query to mutation() and that should invalidate part of the cache? if not all?? I'm lost here and considering writing URQL out of my project... please help |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 28 replies
-
|
UPDATE: I thought it might an issue of the closure returned in the hook, but i extracted all the function and just pasted the call where i need it and the problem remains, calling createClient doesn't seem to invalidate cache... |
Beta Was this translation helpful? Give feedback.
-
|
All right let's look at the problem first, what triggers this data to be different every time? If it's you interacting with the data then a useMutation is needed to show these interactions. If it's other people interacting with the data we will need a useSubscription. If this one query is just truely dynamic try using fetchPolicy: 'network-only'. What makes the query dynamic? Resetting the client shouldn't be needed? If possible reproduce it on codesandbox and we'll gladly point you in the right direction. Sidenote: what about the graphCache types isn't working? Just tried it and worked. |
Beta Was this translation helpful? Give feedback.
-
|
It took me a while to understand how to fix this, here's the solution |
Beta Was this translation helpful? Give feedback.
It took me a while to understand how to fix this, here's the solution
#1339 (comment)