SwiftGraphQL’s caching mechanisms are heavily inspired by Urql.
cacheFirst
(default) - prefers cached results and falls back to sending a network request when there’s no existing cachecacheAndNetwork
- returns cached results immediately but also sends an API request and updates the data on responsenetworkOnly
- always sensds a network request and ignores cache entirelycacheOnly
- always returns cached result or nil
Regardless of your query caching option SwiftGraphQL caches your result if some other part of your code may want to reuse it.
[Post]
then a mutation createPost
that returns a new Post
triggers re-execution of that feed query automatically.
If your queries are deep and depend on many types, they are more likely to be automatically revalidated.
🚧 A normalized caching exchange is a work in progress. You are welcome to contribute your knowledge, ideas and code on the repository.