Closed
Description
Let's say I have a graphql schema with a field that looks like this:
fields := graphql.Fields{
"hello": &graphql.Field{
Type: graphql.String,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
return nil, errors.New("Whoops! An error occurred")
},
},
}
The result would be:
{
"data": {
"test": {
"id": null,
}
},
"errors": [
{
"message": "Whoops! An error occurred",
"locations": [
]
}
]
}
What I would like to do is to be able to add extra fields to the errors object. For example:
{
"data": {
"test": {
"id": null,
}
},
"errors": [
{
"message": "Whoops! An error occurred",
"locations": [
],
"field": "hello",
"code": "WHOOPS_ERROR"
}
]
}
It would be really cool if there's way to be able to add these extra fields into the error message when an error happens.