Skip to content

MBL-915: Replace LegacyInterceptorProvider#2477

Merged
amy-at-kickstarter merged 4 commits into
mainfrom
feat/adyer/upgrade-apollo-prep-1
Jun 20, 2025
Merged

MBL-915: Replace LegacyInterceptorProvider#2477
amy-at-kickstarter merged 4 commits into
mainfrom
feat/adyer/upgrade-apollo-prep-1

Conversation

@amy-at-kickstarter

@amy-at-kickstarter amy-at-kickstarter commented Jun 16, 2025

Copy link
Copy Markdown
Contributor

📲 What

Replace LegacyInterceptorProvider with equivalent code. This makes our NetworkInterceptorProvider conform directly to InterceptorProvider, but implements identical behavior to LegacyInterceptorProvider

🤔 Why

Apollo 1.0 removes the LegacyInterceptorProvider class. By upgrading this now, there will be one less thing to fix when we upgrade Apollo.

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 {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@amy-at-kickstarter amy-at-kickstarter marked this pull request as ready for review June 16, 2025 18:05
@amy-at-kickstarter amy-at-kickstarter requested review from a team, ifosli and stevestreza-ksr and removed request for a team June 16, 2025 18:05
@amy-at-kickstarter

Copy link
Copy Markdown
Contributor Author

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funky line breaking here

}

func additionalErrorInterceptor<Operation: GraphQLOperation>(for _: Operation) -> ApolloErrorInterceptor? {
return nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe toss in a FIXME to do something more useful with error handling if this is where we can collect them for any query.

@amy-at-kickstarter amy-at-kickstarter merged commit 05740e6 into main Jun 20, 2025
5 checks passed
@amy-at-kickstarter amy-at-kickstarter deleted the feat/adyer/upgrade-apollo-prep-1 branch June 20, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants