Apollo iOS 1.5 migration guide

From 1.3 - 1.4 to 1.5


This guide describes the process of migrating your code from version 1.3 or 1.4 to version 1.5 of Apollo iOS.

Key Changes

Version 1.5 is a minor version bump, and will require no migration for most users.

  • For users using the standard ApolloClient class, this version will be a seamless upgrade with no changes to your existing code required.

  • For users with custom client implementations that conform to ApolloClientProtocol, a simple migration is required.

While we strive to make the upgrade path for minor versions seamless, these improvements could not be made without requiring this migration. For those users affected, follow this migration guide to update to 1.5.

Request Context

1.5 added the ability to pass a custom request context to networking APIs. The fetch, watch, perform, upload or subscribe methods now accept an optional RequestContext parameter which is used to construct the request and is then available to any interceptor in the interceptor request chain.

If you had code that conformed to ApolloClientProtocol like the example below:

Swift
v1.5 migration example
1class MyCustomClient : ApolloClientProtocol {
2  public func fetch<Query: GraphQLQuery>(
3    query: Query,
4    cachePolicy: CachePolicy = .default,
5    contextIdentifier: UUID? = nil,
6    queue: DispatchQueue = .main,
7    resultHandler: GraphQLResultHandler<Query.Data>? = nil
8  ) -> Cancellable {
9    ..
10  }
11
12  // other ApolloClientProtocol methods
13}

You would simply have to add the new property to the method definition:

Swift
v1.5 migration example
1class MyCustomClient : ApolloClientProtocol {
2  public func fetch<Query: GraphQLQuery>(
3    query: Query,
4    cachePolicy: CachePolicy = .default,
5    contextIdentifier: UUID? = nil,
6    context: RequestContext? = nil,
7    queue: DispatchQueue = .main,
8    resultHandler: GraphQLResultHandler<Query.Data>? = nil
9  ) -> Cancellable {
10    ..
11  }
12
13  // other ApolloClientProtocol methods
14}
Feedback

Edit on GitHub

Forums