1

I implemented a graphql server using graphql-java that offers subscriptions over websockets.

When I subscribe using the websocket CL-tool wscat everything works as intended.

Here is how the data looks that the server publishes (<):

$wscat -c "ws://localhost:9876/subscriptions"
> { "query" : "subscription{resourceSubscription(hasTypes : []){id}}" }
< {"type":"subscription_success"}   
< {"payload":{"data":{"resourceSubscription":{"id":"..."}}},"id":"1","type":"subscription_data"} (*1)

The JSON response format is copied from this tutorial. I have also tried to just send the "data" block without the "payload" wrapper.

For graphiql I use the graphiql-spring-boot-starter v7.1.0 package. When I fire a subscription from graphiql, the display shows:

"Your subscription data will appear here after server publication!"

graphiql sends the query to the websocket endpoint:

{"type":"connection_init","payload":{}}

{"id":"1","type":"start","payload":{"query":"subscription[...]","variables":null}}

A websocket is created on the server, and new data is actually published to the established websocket (like in *1), however, it is not displayed in graphiql, the incoming data is completely ignored and the prompt remains.

Does anyone have an idea why this happens? Is the JSON response not formatted correctly?

1 Answers1

0

The necessary response types is: {"type": "data",...} instead of {"type" : "subscription_data",...}