-
Notifications
You must be signed in to change notification settings - Fork 112
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
Subscription connection parameters support #360
base: main
Are you sure you want to change the base?
Conversation
089fdf8
to
37fe24f
Compare
graphql/client.go
Outdated
// | ||
// connectionParams is a map of connection parameters to be sent to the server | ||
// during the initial connection handshake. | ||
func NewClientUsingWebSocketWithConnectionParams(endpoint string, wsDialer Dialer, headers http.Header, connParams map[string]any) WebSocketClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there was never a a release that includes NewClientUsingWebSocket
, we should be free to update the signature if we want, and possible only have one function:
func NewClientUsingWebSocket(endpoint string, wsDialer Dialer, headers http.Header, connParams map[string]any) WebSocketClient
37fe24f
to
a8e9201
Compare
A big gotcha regarding HTTP headers and connection parameters, that I realized recently, is that websocket requests in 99desgins gqlgen enter a different path, going through here: gqlgenServer.AddTransport(transport.Websocket{
InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, *transport.InitPayload, error) {
// initPayload contains connection parameters
},
}) than the middleware path that would normally be expected: r.With(ah.VerifyAuthMiddleware).Method(http.MethodPost, "/v1", c.GraphServer)
r.With(ah.VerifyAuthMiddleware).Method(http.MethodGet, "/v1", c.GraphServer) |
a8e9201
to
569efb2
Compare
569efb2
to
5775169
Compare
Ping @benjaminjkraft and @matthieu4294967296moineau, do you think it would be possible to get a quick look here? 🤗 |
Ping @benjaminjkraft 🤗 |
Adds support for subscription (websocket) connection parameters support.
We are having an issue with authorization when using subscriptions in genqlient. Our mobile app team is using Apollo for GraphQL requests, and Apollo seems to sends its auth in a way that is different from how genqlient does it:
https://www.apollographql.com/docs/react/data/subscriptions#5-authenticate-over-websocket-optional
This is causing a problems, because we use genqlient for testing the backend. It seems that the way Apollo is implemented, authentication (and other headers) are not actually sent as HTTP headers, but as connection parameters instead.
I have: