graphql-spring-boot icon indicating copy to clipboard operation
graphql-spring-boot copied to clipboard

Subscription error response does not comply with the GraphQL specification

Open BlasiusSecundus opened this issue 5 years ago • 5 comments

According to the GraphQL specification if an error occurs the response should contain a non-empty errors array.

In case of queries and mutations, this works correctly. E. g. the following response is returned:

{
  "errors": [
    {
      "message": "Internal Server Error(s) while executing query"
    }
  ],
  "data": null
}

However, in case of subscriptions, a single error object is returned:

{
  "error": {
    "message": "Internal Server Error(s) while executing query"
  }
}

This seems to be a violation of specs, and could cause issues for clients that expect a specification-compliant response.

Tested versions: 6.0.1, current (as of commit 0f948f8) master

BlasiusSecundus avatar Mar 14 '20 15:03 BlasiusSecundus

Just checked this issue again with 7.0.1 (perhaps the same with 6.0.1) from the network log it appears that it does send errors array, but Playground displays it incorrectly?

image

BlasiusSecundus avatar Apr 08 '20 18:04 BlasiusSecundus

@BlasiusSecundus Just tested this with GraphiQL and there I see the subscription is really sending the correct response, like you've also confirmed already with the dev console. Not sure if this still happens with Playground, but maybe raise an issue with that project instead?

oliemansm avatar Dec 20 '20 12:12 oliemansm

I'll check again if it can be reproduced with the new, updated Playground.

BlasiusSecundus avatar Dec 20 '20 12:12 BlasiusSecundus

@BlasiusSecundus Is this still a thing or can we close the issue?

oliemansm avatar May 06 '21 20:05 oliemansm

Most likely yes. This test is actually verifying that the correct error message is sent by the server: https://github.com/graphql-java-kickstart/graphql-spring-boot/blob/master/graphql-spring-boot-test/src/test/java/com/graphql/spring/boot/test/GraphQLTestSubscriptionErrorTest.java

Received message from web socket: {"type":"error","id":"2","payload":{"errors":[{"message":"Internal Server Error(s) while executing query","locations":[]}]}}

I have to check Playground.

BlasiusSecundus avatar May 07 '21 05:05 BlasiusSecundus