title: Apollo client & Hasura authentication on iOS
body: <p>I'm trying to implement a subscription using apollo client on iOS and I've looked into <a href="https://stackoverflow.com/questions/51720378/how-to-implement-graphql-subscription-using-apollo-ios-client">this</a> thread but it doesn't work for me. I'm still getting this <code>Authentication hook unauthorized this request, code: 1000</code> or <code>Operation couldn't be completed Starscream.WSError error 1</code></p>
  
  <p>My code is:</p>
  
  <pre><code>let apollo: ApolloClient = {
      let authPayload = ["X-Hasura-Access-Key": "&lt;my_key&gt;",
                         "Content-Type": "application/json"]
  
      let configuration = URLSessionConfiguration.default
      configuration.httpAdditionalHeaders = authPayload
  
      let map: GraphQLMap = authPayload
  
      let url = URL(string: "https://url")!
      let wsUrl = URL(string: "wss://url")!
  
      let httpNetworkTransport = HTTPNetworkTransport(url: url, configuration: configuration)
      let wsNetworkTransport = WebSocketTransport(request: URLRequest(url: wsUrl), connectingPayload: map)
  
      return ApolloClient(networkTransport: SplitNetworkTransport(httpNetworkTransport: httpNetworkTransport,
                                                              webSocketNetworkTransport: wsNetworkTransport))
  }()
  </code></pre>
  
  <p>It's working fine with queries though, but not with websocket and subscriptions. What am I doing wrong?</p>
  
  <p>UPD: It's interesting, but if I remove the payload in the wsNetworkTransport, the error stays the same. Also if I add the request headers manually through <code>request.addValue</code>, the error again the same.</p>
  
  <p>I'm calling the client like so: </p>
  
  <pre><code>apollo.subscribe(subscription: OrdersSubscription(id: "123")) { (result, error) in
          error == nil ? print(result!) : print(error!)
  }
  </code></pre>
  
  <p>Is there any additional setup I'm missing? This thing really lack the docs.</p>