Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning error from subscription doesn't return a proper Graphql Error payload #4208

Closed
MohamedSabthar opened this issue Mar 15, 2023 · 0 comments · Fixed by ballerina-platform/module-ballerina-graphql#1293
Assignees
Labels
module/graphql Issues related to Ballerina GraphQL module Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/PCM Protocol connector packages related issues Type/Bug
Milestone

Comments

@MohamedSabthar
Copy link
Member

Description:
Consider the following graphql service and the subscription query
Service

service /graphql on new graphql:Listener(4000) {

    resource function get geeting() returns string {
        return "Welcome to Book Review Service";
    }

    resource function subscribe data() returns stream<int, error?>|error {
        return error("an error occured");
    }
}

Query

subscription {
  data
}

The above query returns the following output

{
  "type": "error",
  "id": "1",
  "payload": [
    {
      "message": "an error occurred"
    }
  ]
}

which does not conform to the standard format for GraphQL errors. The expected error response should include additional information such as the location and path of the error. Following is the expected response

{
  "type": "error",
  "id": "1",
  "payload": [
    {
      "message": "an error occurred",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "data"
      ]
    }
  ]
}

Steps to reproduce:

Affected Versions:
Update 3,4

OS, DB, other environment details and versions:

Related Issues (optional):

Suggested Labels (optional):

Suggested Assignees (optional):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/graphql Issues related to Ballerina GraphQL module Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/PCM Protocol connector packages related issues Type/Bug
Projects
Archived in project
2 participants