-
Notifications
You must be signed in to change notification settings - Fork 746
Use the same URLSession as my main networking stack? #2851
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
Comments
I have the same expectation as you that using the same configuration ( I unfortunately don't have any other suggestions. Are you able to use the shared session cookie in another |
Thanks for your reply! I just wanted to double-check that I wasn't misunderstanding something on Apollo's side... I think I figured out what was happening... the 2 APIs (non-GraphQL vs. GraphQL) are actually on different domains right now, I assume the cookies are restricted to a given domain and therefore, even though the same session configuration is used, they're not shared between the 2 🤦♂️ |
Yes, that make sense as the limitation. Thanks for following up. |
Honestly it would be really nice to be able to create our own |
Thanks @RamblinWreck77. One problem with this approach is |
@calvincestari In my case my existing API implementation uses the new async/await calls on URLSession, the oldschool delegate stuff isn't used at all. Also, this is totally a hack but I think I found a way @SilverTab to do what you want (I wanted to use the same URLSession for GraphQL/Apollo as my legacy API). I modified my Apollo Client setup code to take in a static URLSession client like:
(sorry, indention is so weird on github) Then, over in my legacy API:
I'm trying to see if there's any problems with doing this, so far everything works as expected and we're back to 1 URLSession! |
Sorry for commenting on this issue after a long time, but we're running into the same problems. We're transitioning slowly from Alamofire to GraphQL. We have a pretty complex authentication system which now runs side by side e.g. Interceptors (Apollo) & RequestAdapter / Retrier (Alamofire). |
@TripwireNL - the 1.x versions will unfortunately remain this way. Good news though is that we're working on 2.0 (RFC) which is being designed to allow for the kind of |
Question
I'm not sure if what I'm trying to do is possible, or if it makes sense, but here's what I am trying to achieve: We're transitioning progressively to GraphQL in our app, and for queries that requires a user to be authenticated to work, I need to pass in a
sessionid
cookie that was acquired in our app's main URLSession (so in other words, our old non-GraphQL API, and our new GraphQL endpoint both work for authenticated queries, using the samesessionid
cookie).Our main (non-GraphQL) networking stack uses a URLSession that is initialized with the
.default
configuration, and after logging in, using ProxyMan, I can see that the sessionid cookie is present.Now, when setting up the Apollo client, I'm doing this:
However, when I inspect the queries made to our GraphQL endpoint in proxyman, I do see a
sessionid
cookie being sent, BUT it's a different session id than the one I see on requests to our non-GraphQL endpoint.Am I doing something wrong? Is there a way for the GraphQL client's URLSession, and our non-GraphQL client to share a
sessionid
cookie?The text was updated successfully, but these errors were encountered: