I try to initialise Apollo client and get error: Extra argument 'configuration' in call. What's wrong with my code:
//// Apollo Client
let apollo: ApolloClient = {
let accessToken: String = KeychainWrapper.standard.string(forKey: "token")!
let graphEndpoint = "https://graphqlendpoint.com/graphql"
let authPayloads = ["Authorization": "Bearer \(accessToken)"]
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = authPayloads
let endpointURL = URL(string: graphEndpoint)!
return ApolloClient(
networkTransport: HTTPNetworkTransport(
url: endpointURL,
configuration: configuration)
)
}()
I use Xcode Version 11.0 (11A420a)
Solved:
/// Apollo Client
let apollo: ApolloClient = {
let configuration = URLSessionConfiguration.default
var authValue: String? = "Bearer \(accessToken)"
let authPayloads = ["Authorization": authValue ?? ""]
let graphEndpoint = "https://graphqlendpoint.com/graphql"
configuration.httpAdditionalHeaders = authPayloads
let endpointURL = URL(string: graphEndpoint)!
return ApolloClient(
networkTransport: HTTPNetworkTransport( url: endpointURL, session: URLSession(configuration: configuration))
)
}()
@bizmedia Thanks for posting the solution - Yes, there were some changes to HTTPNetworkTransport and it now takes a URLSession directly rather than a URLSessionConfiguration
Most helpful comment
Solved: