Search code examples
iosgraphqlapolloautomatic-persisted-queries

GraphQL iOS Apollo Client Automatic Persisted Queries Causing a Crash


Looking to get some help with setup of APQ's on the iOS Apollo SDK, using version of Apollo 1.2.2 and when turned on the APQ as:

 let transport = RequestChainNetworkTransport(interceptorProvider: provider,
                                                     endpointURL: url,
                                                     autoPersistQueries: true)

Getting an error on query fetch as:

  Apollo/RequestBodyCreator.swift:47: Fatal error: To enable autoPersistQueries, Apollo types must be generated with operationIdentifiers 

I did add this snippet to config and re-ran code gen via cli:

  "options": {
       "operationDocumentFormat" : [
         "definition",
         "operationId"
       ]
  }

Solution

  • We ran into this same issue with 1.2. We upgraded to 1.7 and the issue was no longer. Wasn't much involved with the upgrade either. A few items were deprecated but everything continued to work as is.