graphql-spring-boot
graphql-spring-boot copied to clipboard
Support graphql-ws
Hi.
I tried to use this library with JS client. All tutorials about it said, that need use "graphql-ws" library for subscriptions. But all worked examples of servers with this library used "subscriptions-transport-ws".
NPM install for this JS-library says
The `subscriptions-transport-ws` package is no longer maintained. We recommend you use `graphql-ws` instead. For help migrating Apollo software to `graphql-ws`, see https://www.apollographql.co
m/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws For general help using `graphql-ws`, see https://github.com/enisdenjo/graphql-ws/blob/master/README.md
So I have question - I there is a way to switch library WebSocket support to graphql-ws either - do you have plan to support it?
I've added my client. To checking it on your own project, you can change parts of code under //TODO dist.zip
Best regards. Alexey
I've notice, that subscriptions are broken since 12.0.0 version. For version 11.0.0 all is good
Do you have spring-boot-starter-websocket
in your dependencies? In 11.0.0 it would automatically pull in all sorts of spring boot starters, while in 12.0.0 it relies on you to add the proper dependencies. Then the kickstart starter will only enable features depending on things that are on the classpath. Meaning if you do not have a websocket starter on your classpath it will not configure support for subscriptions.
In gradle it would be:
implementation 'org.springframework.boot:spring-boot-starter-websocket:2.6.7'
Thanks for quick response. This fixes second notice. But apollo client, based on graphql-ws still not working.
There should be some documentation on the Apollo repo on how to migrate from subscriptions-transport-ws to graphql-ws. The underlying protocol should still be the same, it's just a matter of how to set it up on the client side that's changed. Support for that is out of scope of this project.
The underlying protocol is not the same i think, mainly because GraphQL did not define it in any spec (see here: https://www.apollographql.com/docs/react/data/subscriptions/#choosing-a-subscription-library). graphql-ws
besides also supporting the subscription
operation, allows to use GraphQL over WS entirely (unless i misunderstood something). More discussion here: https://github.com/graphql/graphql-over-http/pull/140.
I am not sure if this is matured enough already to warrant any work. Although with Apollo already having this implemented it is probably somewhat safe to say that it will stay.
This is the new protocol: https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md
The correct repo for this would probably be: https://github.com/graphql-java-kickstart/graphql-java-servlet