I would like to display a loading state only if apollo is going to hit the network to avoid having a loading state quickly flash in the cases that apollo can pull the data from the cache.
I haven't found a way yet, without manually reading from the cache before attempting a fetch, to do this.
This relates to https://github.com/apollographql/apollo-android/issues/588 on the Android side and they have some discussion about api design for java, along with some of the limitations of java in comparison to swift influencing their design.
If there's interest in this I can work on a solution and open a PR
Does the returnCacheDataAndFetch caching option not do this already? It's possible it was added since this issue was opened but if it doesn't do this, that's likely a bug
the returnCacheDataAndFetch does do this. However, returnCacheDataElseFetch I do not believe does.
That is correct - the else is basically "Attempt to load from cache, then attempt to load from internet if that failed. The and is basically "Attempt to load from cache, then attempt to load from internet no matter what". I recently updated the documentation on these, so hopefully that will help others running into the same issue.
Anything else I can help with here, or do you mind if I close this issue out?
Since I haven't heard back on this one in a couple weeks, I'm going to close it out. If you're still having problems around this, please open a new issue or drop by our Spectrum Chat if you've got questions. Thanks!
Most helpful comment
If there's interest in this I can work on a solution and open a PR