graphql-java-generator / graphql-gradle-plugin-project

graphql-gradle-plugin is a Gradle Plugin for GraphQL, based on graphql-java. It accelerates the development for both the client and the server, by generating the Java code. It allows a quicker development when in contract-first approach, by avoiding to code the boilerplate code.
https://graphql-maven-plugin-project.graphql-java-generator.com/
MIT License
54 stars 8 forks source link

Websocket connnection with Sec-WebSocket-Protocol: graphql-ws header #8

Closed fschmuck closed 2 years ago

fschmuck commented 3 years ago

Does the current implementation support the Sec-WebSocket-Protocol: graphql-ws header? Because when I want to establish a connection with this header from my frontend-client the connection will be closed instantly.

etienne-sf commented 3 years ago

Hum, I am afraid I missed something there.

Yes, the low level is not properly implemented. It works when both sides (client and server) are generated code by the plug-in. But it won't work with another (standard) implementation.

I'll work quickly on this one. But it will take some days.

Étienne

fschmuck commented 3 years ago

Thank you very much.

Would it be a viable approach to implement the SubProtocolCapable interface on the generated WebsocketHandler and set allowed subprotocols via the plugin configuration?

etienne-sf commented 3 years ago

It seems a good idea, as it would allow a retro-compatibility with the existing code. There is currently no way to add a new protocol per configuration in the plug-in. So this would need a patch.

That being said, AFAIK, the current and only protocol that is really managed is the graphql-transport-ws protocol, as specified by graphql-ws. Are we speaking about the same thing ?

Étienne

fschmuck commented 2 years ago

Yes, right.

etienne-sf commented 2 years ago

Update:

I'm working on this subject, and it's quite a mess.

Apollo-server-express implements this Sec-WebSocket-Protocol: graphql-ws header. The name of the protocol, in the http GET Web Socket exchange is graphql-ws, as you pointed out. From the doc, what's behind is actually subscription-transport-ws (which is deprecated and no longer maintained), and this is the library that is included.

But graphql-ws is also the name of the library (not included in apollo-server-express apparently), that defines and implement the graphql-transport-ws protocol. This one seems to be the future of subscription. But not currently implemented in Apollo (again, from the docs)

:(

I implemented the graphql-transport-ws, and I will make it available in the next release.

But I think it won't solve this issue.

I'll continue digging into this, and see how to be compliant with this Sec-WebSocket-Protocol: graphql-ws header, that Apollo accepts.

Etienne

etienne-sf commented 2 years ago

No news on this issue, since the delivery of the graphql-transport-ws.

Closing this issue