MBL-915: Replace LegacyInterceptorProvider#2477
Conversation
Apollo 1.0 and beyond remove the LegacyInterceptorProvider class. This replaces it, and also removes LegacyParsingInterceptor from our interceptor chain, which has no equivalent in 1.0.
| /// That's provider is longer included in Apollo 1.x, but we want to continue to have the same | ||
| /// behavior. This could, potentailly, be cleaned up to remove unnecessary interceptors. | ||
| class | ||
| NetworkInterceptorProvider: InterceptorProvider { |
There was a problem hiding this comment.
This class is now an amalgamation of what we had implemented in NetworkInterceptorProvider, and what Apollo provided in LegacyInterceptorProvider: https://github.com/apollographql/apollo-ios/blob/0.44.0/Sources/Apollo/InterceptorProvider.swift#L31-L72
Essentially, I copy-pasted LegacyInterceptorProvider, harcoded the defaults we weren't changing (shouldInvalidateClientOnDeinit and client), and added HeadersInterceptor to the stack.
It should be 100% equivalent to the old InterceptorProvider, just rejiggered a bit.
|
Regarding feature flags! I'm considering gating this behind a flag, but because the Apollo client is set up at launch, I'm not really sure it would do us much good. Thoughts? |
| /// That's provider is longer included in Apollo 1.x, but we want to continue to have the same | ||
| /// behavior. This could, potentailly, be cleaned up to remove unnecessary interceptors. | ||
| class | ||
| NetworkInterceptorProvider: InterceptorProvider { |
There was a problem hiding this comment.
Funky line breaking here
| } | ||
|
|
||
| func additionalErrorInterceptor<Operation: GraphQLOperation>(for _: Operation) -> ApolloErrorInterceptor? { | ||
| return nil |
There was a problem hiding this comment.
Maybe toss in a FIXME to do something more useful with error handling if this is where we can collect them for any query.
📲 What
Replace
LegacyInterceptorProviderwith equivalent code. This makes ourNetworkInterceptorProviderconform directly toInterceptorProvider, but implements identical behavior toLegacyInterceptorProvider🤔 Why
Apollo 1.0 removes the
LegacyInterceptorProviderclass. By upgrading this now, there will be one less thing to fix when we upgrade Apollo.