Description
When dealing with error responses on client side, would be nice to know which field caused it. Right now there seems to be support for locations
-> (column: .., line: ...)
, but not for the path
specified in graphql/graphql-spec#230
If an error can be associated to a particular field in the GraphQL result, it must contain an entry with the key path that details the path of the response field which experienced the error. This allows clients to identify whether a null result is intentional or caused by a runtime error.
This field should be a list of path segments starting at the root of the response and ending with the field associated with the error. Path segments that represent fields should be strings, and path segments that represent list indices should be 0‐indexed integers. If the error happens in an aliased field, the path to the error should use the aliased name, since it represents a path in the response, not in the query.
{
hero(episode: $episode) {
name
heroFriends: friends {
id
name
}
}
}
"errors": [
{
"message": "Name for character with ID 1002 could not be fetched.",
"locations": [ { "line": 6, "column": 7 } ],
"path": [ "hero", "heroFriends", 1, "name" ]
}
],
Note: might take a look at this at some point myself (would like to also fine-tune when server side exception prints traceback to logs and/or figuring out how to gracefully report errors to client without exception + traceback on server...)