Skip to content
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

URLSessionClient doesn't use custom URLSessionConfiguration #1230

Closed
iPile opened this issue May 27, 2020 · 7 comments
Closed

URLSessionClient doesn't use custom URLSessionConfiguration #1230

iPile opened this issue May 27, 2020 · 7 comments

Comments

@iPile
Copy link

iPile commented May 27, 2020

After 0.27.0 changes for HTPPNetworkTransport init to use URLSessionClient instead of URLSession, custom URLSessionConfiguration properties such as htppAdditionalHeaders don't get configured.

    let apollo: ApolloClient = {
        let configuration = URLSessionConfiguration.default
        
        configuration.httpAdditionalHeaders = [
            "X-Parse-Application-Id": "appID",
            "X-Parse-Client-Key": "clientID"
        ]
        
        let url = URL(string: "https://parseapi.back4app.com/graphql")!
        let sessionClient = URLSessionClient(sessionConfiguration: configuration)
        
        return ApolloClient(networkTransport: HTTPNetworkTransport(url: url, client:sessionClient))
    }()

Previously using the same URLSessionConfiguration, the HTPPNetworkTransport class got the URLSessionClient configured accordingly and requests were sent correctly.

let apollo: ApolloClient = {
    let configuration = URLSessionConfiguration.default
    configuration.httpAdditionalHeaders = [
            "X-Parse-Application-Id": "appID",
            "X-Parse-Client-Key": "clientID"
    ]

    let url = URL(string: "https://parseapi.back4app.com/graphql")!

    return ApolloClient(networkTransport: HTTPNetworkTransport(url: url, configuration: configuration))
}()
@designatednerd
Copy link
Contributor

That's...very weird. Here's the only place the session is set up, and you can see we're passing the session configuration in directly from the parameter, which it looks like you're passing in appropriately.

What happens if you throw in a breakpoint after you set up sessionClient and po the client's session.configuration?

@iPile
Copy link
Author

iPile commented May 27, 2020

image

image

HTTPNetworkTransport:

image

@designatednerd
Copy link
Contributor

Yeah if those are there, I've got absolutely zero idea why they wouldn't be getting sent with the request.

At what point are you seeing them not being sent with the request, after it hits the wire? Or are you getting an error indicating they're not there?

@iPile
Copy link
Author

iPile commented May 27, 2020

Never mind... Everything works as expected. Sorry for the missleading bug report.

@iPile iPile closed this as completed May 27, 2020
@designatednerd
Copy link
Contributor

No worries, I'm just glad it actually works! 😃

@iPile
Copy link
Author

iPile commented May 27, 2020

We met in last years SwiftAlps and I really admire your work that you're doing here, Ellen!

I'm trying to dig deep now in to GraphQL with Apollo and I hope I'll be able to contribute in the future. Take care!

@designatednerd
Copy link
Contributor

You too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants