apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.87k stars 717 forks source link

Error handling for CacheWriteInterceptor added in 1.14.0 causing issues #3420

Closed aduflo-envoy closed 1 month ago

aduflo-envoy commented 1 month ago

Summary

Apollo 1.14.0 introduced handling of a new edge case for CacheWriteInterceptor, noted as CacheWriteError.missingCacheRecords.

In handling this new edge case, a new control flow was introduced:

guard
      let createdResponse = response,
      let cacheRecords = createdResponse.cacheRecords
    else {
      chain.handleErrorAsync(
        CacheWriteError.missingCacheRecords,
        request: request,
        response: response,
        completion: completion
      )
      return
    }

Given that this control flow calls handleErrorAsync() instead of proceedAsync(), it prematurely exits the request chain.

In 1.13.0, given this edge case was unhandled, the request chain would continue through interceptors registered after CacheWriteInterceptor, so this was a nonissue.

This new control flow changes expectations for Apollo Interceptors, and for my specific use case, I'd need to omit CacheWriteInterceptor from the list of interceptors to reestablish the previous control flow. At this time I'll need to have Apollo marked as 1.13.0 exact version in SPM, until this is adjusted.

Version

1.14.0

Steps to reproduce the behavior

Trigger the edge case outlined above, so anytime there aren't cache records available.

Logs

No response

Anything else?

No response

calvincestari commented 1 month ago

Hi @aduflo-envoy, thanks for reporting the issue. Good news is that this has already been resolved and merged into main. It'll go out in the next release which we're planning to publish this week still.

github-actions[bot] commented 1 month ago

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.