I'm getting close. I was getting rejected for not having the correct headers in my Websocket upgrade. I ended up having to set them directly on the URLRequest
object.
var apollo: ApolloClient? {
let authHeaders = ["X-Hasura-Access-Key": "<my_Key>", "Content-Type": "application/json"]
let configuration = URLSessionConfiguration.default
// Add additional headers as needed
configuration.httpAdditionalHeaders = authHeaders
//The string to my graph QL Server run by Hasure on AWS RDS.
let graphQLEndpoint = "http://<my_host>/v1alpha1/graphql"
let graphQLSubscriptionEndpoint = "ws://<my_host>/v1alpha1/graphql"
//Take my Ec2 Server string and make a URL for the graph QL and subscriptions
guard let httpURL = URL(string: graphQLEndpoint), let webSocketURL = URL(string: graphQLSubscriptionEndpoint) else {
return nil
}
let httpTransport = HTTPNetworkTransport(url: httpURL, configuration: configuration, sendOperationIdentifiers: false)
var request = URLRequest(url: webSocketURL)
request.setValue("<my_key>", forHTTPHeaderField: "X-Hasura-Access-Key")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let webSocketTransport = WebSocketTransport(request: request, sendOperationIdentifiers: false, connectingPayload: nil)
let splitTransport = SplitNetworkTransport(httpNetworkTransport: httpTransport, webSocketNetworkTransport: webSocketTransport)
//Initalize the APolloClient with that URL.
return ApolloClient(networkTransport: splitTransport)
}
The upgrade worked after that.