3

The following example https://github.com/graphql-java/graphql-java-subscription-example which use's graphql-java for subscriptions over a websocket.

How can the same idea be done within the spring version? GraphQLSubscriptionResolver needs to return a publisher but I am unable to work out how this can then be used with a web socket.

The example above seems fine within a none spring version.

user101010101
  • 1,609
  • 6
  • 31
  • 52

3 Answers3

1

A good friend of mine has made an example in his github repository. The code is not the nicest (because it was for our own personal needs) but it is a nice example

Have fun

Community
  • 1
  • 1
Guy Smorodinsky
  • 902
  • 7
  • 16
  • 1
    This example uses the graphql-java-annotations library, but the spring and subscription parts should be the same as if it used graphql-java – Guy Smorodinsky Mar 07 '18 at 20:35
0

Here's a port of the graphql-java example using GraphQL-SPQR with Spring Boot. I'll soon merge it into the GraphQL-SPQR samples project.

Same as with the other answer, while it uses GraphQL-SPQR to generate the schema, the Spring and websockets bit is the same as you'd have with graphql-java directly.

There's now a new and somewhat more realistic example using GraphQL SPQR Spring Boot Starter. It publishes updates when a relevant mutation runs.

kaqqao
  • 12,984
  • 10
  • 64
  • 118
0

I just published a workshop in which you can learn how to implement the subscription operations.

http://graphql-java.wesovilabs.com

Let me know If you have any doubt

I hope you find it useful! Thanks