feat: implement GraphQL over WebSocket Protocol - #686
Conversation
348cd13 to
125b065
Compare
|
Thanks for the PR @amondnet. We will test out the changes. My initial thought is that we need a better name for the module as it can be confusing with the existing websockets implementation that we already support. Having multiple websocket protocols can be very confusing for the user. |
paulbakker
left a comment
There was a problem hiding this comment.
Thanks for starting the conversation about this! If this is the protocol that most folks use, we should obviously support that.
A few things we need to think about and/or test for:
- Can this be used together with the existing implementation? E.g. can both modules be active at the same time? It does look like it, because the new module is registering on
/graphql. - Both WebMVC and Webflux should be supported
- Does this conflict with "normal" queries since it's on
/graphql? (I think this should work, but we need to make sure). - This should be supported by the GraphQL client as well that was recently added.
- Does this impact the Graphiql setup we have?
| package com.netflix.graphql.dgs.transports.websockets | ||
|
|
||
| const val GRAPHQL_TRANSPORT_WS_PROTOCOL = "graphql-transport-ws" // graphql-ws subprotocol | ||
| const val GRAPHQL_SUBSCRIPTIONS_WS_PROTOCOL = "graphql-ws" // subscriptions-transport-ws subprotocol |
There was a problem hiding this comment.
This is not actually supported by the new module right? It's what the existing websocket implementation does.
| include("graphql-dgs-pagination") | ||
| include("graphql-dgs-subscription-types") | ||
| include("graphql-dgs-transports-websockets") | ||
| include("graphql-dgs-transports-websockets-autoconfigure") |
There was a problem hiding this comment.
Is this webflux specific? Can it be used with the webmvc starter as well?
There was a problem hiding this comment.
@paulbakker It can be used with webmvc and webflux.
Yes, I agree. Actually I'm not sure how to name the module. |
|
I see, I missed the part about having support for Queries and mutations as
well with websockets. Given that clarification, I think your existing
module name does seem descriptive enough actually.
…On Sat, Oct 9, 2021 at 7:48 PM amond ***@***.***> wrote:
@srinivasankavitha <https://github.com/srinivasankavitha>
My initial thought is that we need a better name for the module as it can
be confusing with the existing websockets implementation that we already
support. Having multiple websocket protocols can be very confusing for the
user.
Yes, I agree. Actually I'm not sure how to name the module.
graphql-dgs-subscriptions-websockets and graphql-dgs-subscriptions-sse
support only Subscriptions.
GraphQL over WebSockets <https://github.com/enisdenjo/graphql-ws> and GraphQL
over SSE support all 3 GraphQL operations:Queries, Mutations,
Subscriptions. These protocols aims to be standardised and become a part
of GraphQL with the help of the foundation’s GraphQL over HTTP
<https://github.com/graphql/graphql-over-http> work group.
graphql/graphql-over-http#140
<graphql/graphql-over-http#140>
graphql/graphql-over-http#163
<graphql/graphql-over-http#163>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#686 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJ5JPXMFEIKSCTL5CIQ7K6DUGD5INANCNFSM5FS24BHQ>
.
|
|
I still need to review and test this PR, will do so this week.
On Mon, Oct 11, 2021 at 11:05 AM Kavitha Srinivasan ***@***.***>
wrote:
… I see, I missed the part about having support for Queries and mutations as
well with websockets. Given that clarification, I think your existing
module name does seem descriptive enough actually.
On Sat, Oct 9, 2021 at 7:48 PM amond ***@***.***> wrote:
> @srinivasankavitha <https://github.com/srinivasankavitha>
>
> My initial thought is that we need a better name for the module as it can
> be confusing with the existing websockets implementation that we already
> support. Having multiple websocket protocols can be very confusing for the
> user.
>
> Yes, I agree. Actually I'm not sure how to name the module.
> graphql-dgs-subscriptions-websockets and graphql-dgs-subscriptions-sse
> support only Subscriptions.
> GraphQL over WebSockets <https://github.com/enisdenjo/graphql-ws> and GraphQL
> over SSE support all 3 GraphQL operations:Queries, Mutations,
> Subscriptions. These protocols aims to be standardised and become a part
> of GraphQL with the help of the foundation’s GraphQL over HTTP
> <https://github.com/graphql/graphql-over-http> work group.
>
> graphql/graphql-over-http#140
> <graphql/graphql-over-http#140>
> graphql/graphql-over-http#163
> <graphql/graphql-over-http#163>
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#686 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AJ5JPXMFEIKSCTL5CIQ7K6DUGD5INANCNFSM5FS24BHQ>
> .
>
|
| ) | ||
| } | ||
| is Message.PongMessage -> { | ||
| // TODO: onPong |
There was a problem hiding this comment.
Nothing to do here, right?
There was a problem hiding this comment.
@srinivasankavitha According to the spec, it should call the onPong event handler if exists.
| if (session.isOpen) { | ||
| session.sendMessage(jsonMessage) | ||
| } | ||
| } |
There was a problem hiding this comment.
Do we need to cleanup the context for this subscription id from the session upon error?
contexts[session.id]?.subscriptions?.remove(id)
|
What set up are you using for the client to test the server? Are you using Apollo client with |
|
@amondnet - when you get a chance, could you describe your set up that you used to test this? Do you have an apollo client set up with the graphql-ws library or do you have your own client? If you have any client code that you can share, much appreciated. |
|
@srinivasankavitha This weekend I will share testable code. |
|
@amondnet - thanks for adding the test and that looks good. The PR overall looks good to me. I tried to test this with a real client with the DGS based on the docs here: https://github.com/enisdenjo/graphql-ws#use-the-client but it does not seem to work after enabling the new module. Have you been able to set up a client to test this end to end? Could you share what you have, if so? Thanks! |
|
Happy to test my (closed source) application with an Apollo client if you like. Is there any config necessary on the DGS side, or does the client negotiate the subprotocol as part of the handshake or something? |
That would be really helpful! Unfortunately, the testing will involve cloning and building the forked repo with the changes and publishing a local snapshot that you can use in your DGS app. You will also need to add the new module implementation(project(":graphql-dgs-transports-websockets")) in your DGS app to get this functionality. |
Yes, we can use together.
Ok. I will add both.
No conflict. |
07d7587 to
3fcc7c9
Compare
3fcc7c9 to
f3d0e04
Compare
495243c to
8a129cc
Compare
|
Sorry for the delay. I'm still happy to test this if it will help push it through. Unfortunately it's not currently building because of linter errors. |
|
@michaelboyles - I am now able to test this with Apollo client and have some fixes. Will push those in the next day. I will be doing some more testing and likely get this PR merged after next week. Will post updates here. Apologies again for the delay due to conflicting internal priorities. |
|
@amondnet - could you please give me access to push a branch to your fork? I have some fixes based on testing your PR. |
|
@srinivasankavitha I have invited you as a collaborator. |
Pull request checklist
first
Pull Request type
Changes in this PR
Describe the new behavior from this PR, and why it's needed
Issue #684
Alternatives considered
Describe alternative implementation you have considered