How to set response timeout for ApolloClient.
We use whatever is on the URLSessionConfiguration you pass in - the property to set this is called timeoutIntervalForRequest. Per the docs:
The default value is 60.
But I am not able to pass URLSessionConfiguration during ApolloClient object creation.
HTTPNetworkTransport only accepts URL as a init parameter.
Fixed.
let url = URL(string: baseURL)!
let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForResource = 10
let client = URLSessionClient(sessionConfiguration: configuration)
let transport = HTTPNetworkTransport(url: url,
client: client)
return ApolloClient(networkTransport: transport)
Yep, right on. Thanks for posting the solution for future folks!
Most helpful comment
Fixed.
let url = URL(string: baseURL)!
let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForResource = 10
let client = URLSessionClient(sessionConfiguration: configuration)
let transport = HTTPNetworkTransport(url: url,
client: client)
return ApolloClient(networkTransport: transport)