kadirahq/graphql-errors

Custom fields

Closed this issue · 1 comments

How is the recommended approach to return custom fields on graphql errors?
For example, I'd like it to be something like this:

{
  "data": {
    "users": null
  },
  "errors": [
    {
      "code": "TEST0001,
      "message": "Test error"
    }
  ]
}

instead of the default format that only has message and locations fields.

Got it, I had to set the graphqlHTTP's formatError option instead of graphql-errors.