apollo-ios
apollo-ios copied to clipboard
Cache policy is ignored for mutation
Bug report
Mutation sends even when cache policy is set to .fetchIgnoringCacheCompletely
Versions
Please fill in the versions you're currently using:
apollo-iosSDK version: 0.50.0- Xcode version: 13.4.1
- Swift version: 5
- Package manager:
Steps to reproduce
Turn device to airplane mode attempt to send mutation with cache policy set to .fetchIgnoringCacheCompletely wait for failure turn airplane mode off and reestablish connection mutation sends
Further details
Hi 👋🏻 - The defined behaviour for . fetchIgnoringCacheCompletely is /// Always fetch results from the server, and don't store these in the cache.. which indicates it will always attempt to communicate with the server. I'm not sure what behaviour you're expecting with that cache policy, can you provide a bit more detail.
The call has failed due to no connection. Why does it send once the connection becomes reestablished? I do not want this behavior at all.
I also do not understand your expectation. The cache policy means to fetch from the server, so doesn't it make sense that it does that when the connection is reestablished? What do you want? A fetch to go out and fail immediately? The cache policy has nothing to do with the network connection handling, something else must be doing that.
It sounds like the behavior would be in the networking code, though I can't find anything here that would indicate that Apollo is doing anything to wait for a connection. This is all of the apollo built ins. There you can see there are 2 interceptors that use cache policy, CacheReadInterceptor and CacheWriteInterceptor.
I'd think something related to Reachability would be implemented in NetworkFetchInterceptor, but again I do not see it. I don't see it anywhere in the library.
Are you sure this isn't something your code is doing, or maybe even iOS these days?
I'm pretty sure it is not our code. It could be an iOS issue I suppose, maybe it has some kind of internal network cache.
The expectation is simple: if a call is made when no internet connection is present, that call fails and is not automatically retried once connection is re-established.
This sounds like URLSession.waitsForConnectivity = true, are you sure you're not using this line in your project?
https://developer.apple.com/documentation/foundation/urlsessionconfiguration/2908812-waitsforconnectivity

That line is not in our project nor is "waitsForConnectivity" at all.
Are you able to replicate this behaviour in a standalone project?
@MatthewHendy, have you found any additional information on what could be causing this. It seems unlikely that this an issue with Apollo itself.
Closed due to inactivity.