-
Notifications
You must be signed in to change notification settings - Fork 657
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
Is HTTP Cache supposed to evict cached queries when the same query is exectued again and results in network failure? #6313
Comments
This is probably not intentional indeed. I'll remove that check. Thanks for bringing this to our attention 🙏 |
If I can make a suggestion, perhaps it would be more desirable to instead do |
The issue is that by the time we come in If we wanted to postpone writing to the cache to that moment, we'd have to keep both requests in memory, which doesn't feel great. I can definitely understand your point though. It's weird to have data being removed because now they have GraphQL errors. All in all, I'd say, using Not sure how many implementations in the wild are relying on that behaviour so I'm not thrilled at the idea of changing it but maybe we could add a flag to switch to that behaviour. |
If we decide to go that way, I'd like to document a use case. Can you share how your backend is working?
|
I'm using an API and as far as I can tell they do not use GraphQL errors, and I do not handle them in my application (i.e. it's either success or failure in the form of As for what I'm using this for, I have just one screen which fetches a query, and I'm trying to somewhat emulate the |
Gotcha, thanks for the context 🙏 For now, I'd suggest we do not add a |
* HTTP cache: do not remove cached entries on transport errors See #6313 * only filter out ApolloNetworkErrors
Question
Consider this chain of events
I would expect it to still be in the cache, but when this scenario happens in my case, the query is no longer there and I am getting a cache miss exception.
After investigating, I found that
HttpCacheApolloInterceptor
removes queries from cache when the response was unsuccessful (has GQL errors or exceptions). However, looking at the code forCachingHttpInterceptor
, the network fetchnetworkMightThrow
function callschain.proceed(request)
first thing, which would throw a network exception when there is no internet, so the rest ofnetworkMightThrow
, the part that puts the response in the cache, won't get called (from what I understand).Is removing the cached query response in cases like these intentional?
The text was updated successfully, but these errors were encountered: