websocket client use websocket subprotocol header during handshake - #691
Conversation
bdfaca6 to
9608221
Compare
9608221 to
5b5e478
Compare
|
Thanks for making the updates. One question I still have - are there no other changes needed besides the addition header to support the newer graphql-ws protocol? Seems like we would need an entirely different protocol implementation, no? Or is this PR not intended to address that? Looking through the existing tests, we still need coverage for :
Something similar to existing SSE test basically - https://github.com/Netflix/dgs-framework/blob/master/graphql-dgs-client/src/test/kotlin/com/netflix/graphql/dgs/client/SSESubscriptionGraphQLClientTest.kt Would be good to have this coverage before merging this feature. |
|
@srinivasankavitha Yes, this pr does not include implementation of newer graphql-ws protocol. The subprotocol currently being used by dgs-client is Sec-WebSocket-Protocol; websocket subprotocol:
This pr makes dgs-client compatible with apollo-subscription + subscriptions-transport-ws. In this case, we only need to add the header. If we do that we will no longer be able to use |
1f08bf3 to
359b24c
Compare
|
Generally, we cannot break backwards compatibility. It sounds like this header was a missing detail in the original websocket implementation implementation using |
|
Regarding this comment - |
|
@srinivasankavitha Yes, dgs-client does not work with the apollo server running subscriptions-transport-ws. |
|
Thanks for the explanation and for adding the test against the apollo server. That's a good scenario to add coverage for. Think we will also need to cover the following scenario, right?
|
|
@amondet - thanks a lot for adding more test coverage for the changes. I think the example test with the apollo-server - |
|
The rest of the PR looks really good to me! Thanks for making the changes. I think we can merge once the apollo example is separated out to a different repo. We generally add OSS contribution sto examples in our docs here: https://netflix.github.io/dgs/examples/ |
|
@amondnet Although I agree with @srinivasankavitha that the test container setup is probably a bit more than we want/need for the framework tests, it does look really interesting. May I suggest writing a blog post about that approach? |
|
@srinivasankavitha I removed |
|
Looks good! Thanks so much for all the work and your patience! |
Pull request checklist
first
Pull Request type
Changes in this PR
Describe the new behavior from this PR, and why it's needed
Issue #
WebSocketGraphQLClientclient useSec-WebSocket-Protocolduring handshake.WebSocket RFC defines the use of sub-protocols. During the handshake, the client and server can use the header
Sec-WebSocket-Protocolto agree on a sub-protocol, i.e. a higher, application-level protocol to use. The use of a sub-protocol is not required, but even if not used, applications will still need to choose a message format that both the client and server can understand. That format can be custom, framework-specific, or a standard messaging protocol.If you use subscriptions-transport-ws and protocol is not specified, the subscriptions-transport-ws closes the connection.
https://github.com/apollographql/subscriptions-transport-ws/blob/231c1b0d25b20090033140b83c8a39871d4ed88c/src/server.ts#L143
Alternatives considered
Describe alternative implementation you have considered