-
Notifications
You must be signed in to change notification settings - Fork 722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to utilise Apollo with background session configuration #77
Comments
Resurrecting this old issue but to give some direction to perhaps @attheodo and others, the solution we ultimately ended up using was to serialize our own Since in background, your app is not in control of the network sessions themselves, we found it hard to make a good fit with the |
If you use Alamofire library in the app and/or don't mind having it as a dependency, I've just published a package that solves this problem: https://github.com/maxdesiatov/ApolloAlamofire You can use it like this: import ApolloAlamofire
let c = URLSessionConfiguration.background(withIdentifier: "your-id")
let u = URL(string: "http://localhost:8080/graphql")!
let s = SessionManager(configuration: c)
let t = AlamofireTransport(url: u, sessionManager: s)
let client = ApolloClient(networkTransport: t) I've tested this extensively in an app that utilises background networking and it works perfectly well. The background network code itself is very minimal thanks to great support for background sessions in Alamofire. |
As of If you are still having problems after upgrading, please open a new issue. Thank you! |
Any suggestion after upgrading 0.15.0, how to add configuration in apollo client? |
There's some stuff with the delegate callbacks I missed that I need to deal with in order to make it fully functional 🤦♀ Please follow that issue for further updates. |
Hello, I have an operation that I want to continue running in the background.
I am creating the Apollo client using
let sessionConfig = URLSessionConfiguration.background(withIdentifier: Bundle.main.bundleIdentifier! + ".apolloBackground")
passed in theHTTPNetworkTransport
object.However when I am trying to test how the request behaves in the background, I am getting:
Most probably due to the way Apollo
perform
method works using completion closures.Any ideas on how to work around that?
The text was updated successfully, but these errors were encountered: