-
Hi! We're using graphcache. In a part of our app, we have a flow like this (simplified for this discussion):
This works, but ends up needing a lot of plumbing to manually refresh where the query is used (sometimes items are created by different parts of the UI). I saw the docs on cache invalidation here, but I don't think that works in this case because the cache can't be invalidation immediately after the mutation runs. We need to wait until the job finishes running. Is there a way to manually invalidate the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hiya 👋 Typically for invalidation we’d recommend a Updaters can be used to update a list without a network round trip as this page shows, but you can also use So for instance if you invalidate |
Beta Was this translation helpful? Give feedback.
-
Hi Phil, Thank you for the awesome client. we are facing a similar issue, need to invalidate cache after an external API or some other async task. I think |
Beta Was this translation helpful? Give feedback.
Hiya 👋
Typically for invalidation we’d recommend a
cache.invalidate
call in a custom updater: https://formidable.com/open-source/urql/docs/graphcache/custom-updates/#cacheinvalidateUpdaters can be used to update a list without a network round trip as this page shows, but you can also use
cache.inspectFields
to get more information on some listing fields and invalidate them, which will cause a refetch automatically of queries that contain invalidated entities and fields.So for instance if you invalidate
Query.jobs(...)
from aMutation.addJob(...)
update, then Graphcache recognises that your query will had some of the data it depends on changed, and will issue a refetch automatically. Sin…