Apollo iOS 1.3 migration guide

From 1.2 to 1.3


This guide describes the process of migrating your code from version 1.2 to version 1.3 of Apollo iOS. Please follow the relevant migration guides if you're on a version other than 1.2.

Though 1.3 is a minor version bump, a few critical bugs were fixed in this version that require some breaking changes during the upgrade. While we strive to make the upgrade path for minor versions seamless, these issues could not be reasonably resolved without requiring this migration.

Request Chain Interceptors

The ApolloInterceptor protocol implemented by request chain interceptors has had a minor change in this version. Any custom interceptors you use are now required to be able to identify themselves through a new property.

The RequestChain protocol has also had a minor change in this version. The proceedAsync(request:response:completion:) function has been deprecated and replaced with a function named identically except for the inclusion of the interceptor so that it can be identified. This removes the need for the request chain to maintain index positioning of the list of interceptors.

Migration Steps

In order for your custom interceptors to conform to the protocol change you can simply add the following line to your interceptor.

Swift
Interceptor identification
1public var id: String = UUID().uuidString

Wherever your custom interceptors call back to the request chain you should replace the call to proceedAsync(request:response:completion:) with a call to the new function.

Swift
Resolve deprecation warning
1chain.proceedAsync(
2  request: request,
3  response: response,
4  interceptor: self,
5  completion: completion
6)

Reserved Keyword Type Name Suffxing

When using certain keywords as the name of a GraphQL type the generated code would fail to compile, as a result we decided to enforce the same reserved keyword list already being used for a Selection Set to the following other GraphQL types:

  • Custom Scalar

  • Enum

  • Fragment

  • Input Object

  • Interface

  • Object

  • Union

Names for these types will be checked (case insensitive) against the following reserved list:

  • Any

  • DataDict

  • DocumentType

  • Fragments

  • FragmentContainer

  • ParentType

  • Protocol

  • Schema

  • Selection

  • Self

  • String

  • Bool

  • Int

  • Float

  • Double

  • ID

  • Type

  • Error

  • _

If a reserved keyword is found it will have its type name suffixed based on the type it represents, take the following Enum example:

GraphQL
Enum Example
1enum Type {
2  valueOne
3  valueTwo
4}

This would result in a generated Swift enum that looks like this:

Swift
Generated Enum
1enum Type_Enum: String, EnumType

Not all of the reserved keywords listed cause a compilation error, however we felt it best to apply suffixing to all of them. This could result in some minor breaking changes to your generated code if you are currently using any of the listed reserved keywords and will require you to update their usage to the new suffixed name.

Feedback

Edit on GitHub

Forums