title: How to correctly use Apollo GraphQL on iOS with background session configuration?
body: <p>I use <a href="https://github.com/apollographql/apollo-ios" rel="nofollow noreferrer">Apollo iOS</a> 0.8 with Xcode 9.3, Swift 4.1 and iOS 11, and initialise Apollo client instance like this:</p>
  
  <pre><code>import Apollo
  
  // ... unrelated code skipped
  
  let configuration = URLSessionConfiguration.default
  
  if let token = keychain.accessToken {
    // Add additional headers as needed
    configuration.httpAdditionalHeaders = [
      "Authorization": "Bearer \(token)"
    ]
  }
  
  let graphqlEndpoint = URL("https://sample-server-url/graphql")!
  let client = ApolloClient(networkTransport:
    HTTPNetworkTransport(url: graphqlEndpoint, configuration: configuration))
  </code></pre>
  
  <p>The application works well with all queries and mutations sent to the GraphQL server without a problem, except when the app is in background. As far as I know, with common <code>NSURLSession</code> instance it can be easily solved by switching session configuration to <code>URLSessionConfiguration.background(withIdentifier: "your-session-id")</code>.</p>
  
  <p>But when I replace the line</p>
  
  <pre><code>let configuration = URLSessionConfiguration.default
  </code></pre>
  
  <p>with </p>
  
  <pre><code>let configuration = URLSessionConfiguration.background(withIdentifier: "your-session-id")
  </code></pre>
  
  <p>the app starts crashing with this error: <code>Terminating app due to uncaught exception 'NSGenericException', reason: 'Completion handler blocks are not supported in background sessions. Use a delegate instead.'</code></p>
  
  <p>What's the best way to resolve this error when using Apollo GraphQL or is there any other way to communicate with a GraphQL server in background?</p>