-
Notifications
You must be signed in to change notification settings - Fork 700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Cache Redirects #842
Comments
I would take a look at the updated caching documentation in #851 - You should be able to use the |
@Hbbb Does the caching documentation answer your question? |
I think I may be misunderstanding this. I've implemented The app in question is something I put together for a proof of concept for my company. Let me push what I have up to a public repo and I'll link you to it. It's a tiny amount of code, so it should illustrate the problem quite nicely. Also, full disclosure I'm very new to GraphQL and to iOS development, so this could very well be user error. |
Great, would love to see it - one thing to be aware of is that anything that doesn't have all the pieces of data requested for a particular cache hit is considered a cache miss, and will send requests to the network. |
@Hbbb Did you ever get that sample code together? Would love to get a look. |
Hey @designatednerd! Sorry for the delay on this. Here's the sample code: https://github.com/Hbbb/pokedex-graphql |
OK! So I ran your app while running Charles proxy, and I only saw one call actually go out to the network even when going to several pages. Here's a gif (because for %reasons% GitHub won't let me just upload a damned video) where you can see that a single network call is made when you click the pokeball, and then going into each of the detail screens, nothing hits the network: |
Okay great! I didn't think to inspect the network traffic 🤦♂. I just built and ran the app again and the last thing I'm confused about is why, when I initially tap a cell for a Pokemon that I haven't tapped before, there is a brief delay before the content appears. On subsequent taps, it's as though the screen is pre-rendered and the content appears immediately. Is this delay due to Apollo, or something completely unrelated? |
It may be due to getting the query watcher set up rather than just trying to perform a query, or potentially something where your detail is otherwise constructing itself, but I'm not positive. My best advice is to run the Time Profiler instrument and see where things are causing the main thread to spin. |
@Hbbb since we've found the answer for your question, can we close this issue out? |
Yep. Thanks so much for your time @designatednerd 😄 |
Hi there! I'm currently in the process of putting together a POC for GraphQL for my company and I'm scratching my head on one thing in particular: Cache Redirects.
I have a textbook example of a list view with it's own query, which clicks through to a detail view with a different query, fetching the same data that's already returned from the initial list query. I'm noticing that although the data exists locally, Apollo caches based on the query, not the ID of objects (or their path in the graph, I'm still pretty new to all of this), so the detail view's query is a cache miss and hits the network.
I found a page in the Apollo React documentation that describes the exact functionality that I need: https://www.apollographql.com/docs/react/v2.5/advanced/caching/#cache-redirects-with-cacheredirects
Does this exist in the Swift client? Are there plans to introduce it? Does it already exist and I just missed it?
Thanks for your time!
The text was updated successfully, but these errors were encountered: