apollo-ios icon indicating copy to clipboard operation
apollo-ios copied to clipboard

Cache policy is ignored for mutation

Open MatthewHendy opened this issue 3 years ago • 7 comments

Bug report

Mutation sends even when cache policy is set to .fetchIgnoringCacheCompletely

Versions

Please fill in the versions you're currently using:

  • apollo-ios SDK 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

MatthewHendy avatar Aug 04 '22 20:08 MatthewHendy

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.

calvincestari avatar Aug 05 '22 06:08 calvincestari

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.

MatthewHendy avatar Aug 05 '22 13:08 MatthewHendy

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?

jimisaacs avatar Aug 07 '22 13:08 jimisaacs

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.

MatthewHendy avatar Aug 08 '22 15:08 MatthewHendy

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

Screen Shot 2022-08-09 at 10 01 08

TizianoCoroneo avatar Aug 09 '22 08:08 TizianoCoroneo

That line is not in our project nor is "waitsForConnectivity" at all.

MatthewHendy avatar Aug 09 '22 19:08 MatthewHendy

Are you able to replicate this behaviour in a standalone project?

calvincestari avatar Aug 09 '22 19:08 calvincestari

@MatthewHendy, have you found any additional information on what could be causing this. It seems unlikely that this an issue with Apollo itself.

AnthonyMDev avatar Aug 23 '22 16:08 AnthonyMDev

Closed due to inactivity.

AnthonyMDev avatar Sep 15 '22 18:09 AnthonyMDev