-
Notifications
You must be signed in to change notification settings - Fork 136
Dim/ws fixes #272
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
Dim/ws fixes #272
Conversation
|
Hi, thanks for your contribution. I'll try to find some time to review this sometime this week... |
|
Hi @rose-a! No worries. I'm totally not sure that this is the right approach, or that it actually solves a proper problem, as authentication overall is a mess in the ecosystem, with very vague approaches. The only thing i'm sure about is the last part, re the binary message not supported on close events :) |
I totally agree with you on that 😉 🙈 Regarding the authentication part: Im worried that other GraphQL servers might vomit on the unexpected payload... I'd really like to not have this as default behaviour, since as you stated above there is no "standard" approach to authorization when using a GraphQL websocket connection. Maybe we could configure a |
|
I cherrypicked your "undisputed" changes into V3.1.7. Please rebase and let us focus on the authentication part in this PR. |
|
Okay! I'll try to have a look this weekend, if that's fine! Sounds feasible; I do understand the concerns regarding clutter. If any suggestions pop by in the meantime, let me know - I definitively have less good of a grasp on the client internals than you :) |
|
Every time that I try to subscribe to a GraphQL API that use Apollo Server I'm getting this message "Object reference not set to an instance of an object" I think is a problem with authentication. |
|
@rose-a @didimitrie any idea when this will be released? |
|
I promised I'll cleanup as per @rose-a's suggestions and didn't follow up 😳 I'll try to get to it! |
|
@didimitrie The missing parts of this PR will end up in #294, so I'm going to close this one... feel free to comment on #294! |
|
Thanks! And sorry for not delivering. Nevertheless, great news re #294! |
Attempts a fix #269 and potentially fixes (or clarifies more) the problem on #250. Defintively fixes the problem on our end!
What's the issue at hand: when connecting to an apollo server subscription endpoint, if an authorization header is present, the server expects it passed in the
connection_initevent like so:graphql-client was not passing that along. This PR simply checks in the provided httpClient if there is an
Authorizationheader and, if so, passes it along by adding it to theconnection_initrequest inCreateSubscriptionStream:Relying on a custom http client being passed with custom default request headers as we didn't find out a better way of setting them currently.
Happy to rework if there's a better way of doing this.
To clarify re #250: we were getting the same "binary websocket messages are not supported" error, but the actually it was a close event. Changed those
if elsestatements to a switch :)