You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the recent change resolving retain cycles our ApolloClient is going out of scope and being deallocated. We were using a computed property on our singleton class because we specify an x-auth-token in the URLSessionConfiguration 's httpAdditionalHeaders which can change throughout the lifecycle of the app. If they log out and log into a different account we can't continue using the same x-auth-token in the ApolloClient, so it was easy for us to create an instance for each request to ensure it would always be correctly configured. With this change we need to rethink this. Is there a way to modify the client's network transport's session's configuration's httpAdditionalHeaders or how would you propose fixing this?
I thought we could still create a new one but store it in a non-computed property on the class but this doesn't work for some reason, fetches never call the result handler.
Thanks!
private var storedApollo: ApolloClient? //must be held onto strongly
var apollo: ApolloClient {
get {
let configuration = URLSessionConfiguration.ephemeral
if let authToken = RestNetworking.shared.authToken {
configuration.httpAdditionalHeaders?["x-auth-token"] = authToken
}
let url = RestNetworking.shared.urlComponents.url!.appendingPathComponent("graphql")
let transport = HTTPNetworkTransport(url: url, session: URLSession(configuration: configuration))
storedApollo = ApolloClient(networkTransport: transport)
return storedApollo!
}
}
The text was updated successfully, but these errors were encountered:
With the recent change resolving retain cycles our ApolloClient is going out of scope and being deallocated. We were using a computed property on our singleton class because we specify an
x-auth-token
in the URLSessionConfiguration 'shttpAdditionalHeaders
which can change throughout the lifecycle of the app. If they log out and log into a different account we can't continue using the samex-auth-token
in the ApolloClient, so it was easy for us to create an instance for each request to ensure it would always be correctly configured. With this change we need to rethink this. Is there a way to modify the client's network transport's session's configuration'shttpAdditionalHeaders
or how would you propose fixing this?I thought we could still create a new one but store it in a non-computed property on the class but this doesn't work for some reason, fetches never call the result handler.
Thanks!
The text was updated successfully, but these errors were encountered: