Skip to content

Instantly share code, notes, and snippets.

@navsing
Created January 6, 2023 18:48
Show Gist options
  • Save navsing/ff4439c0c2424db04e67d8ab9828790b to your computer and use it in GitHub Desktop.
Save navsing/ff4439c0c2424db04e67d8ab9828790b to your computer and use it in GitHub Desktop.
Network Layer
import Foundation
import Apollo
class Network {
static let shared = Network()
let apollo: ApolloClient = {
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = [
"x-api-key": "<YOUR-API-KEY>"
]
let url = URL(string: "<YOUR-GRAPHQL-ENDPOINT>")!
return ApolloClient(
networkTransport: HTTPNetworkTransport( url: url, session: URLSession(configuration: configuration))
)
}()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment