-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Today, GraphQLError only supports the required message field, optional locations field, and optional additional custom field(s). It is missing the path field, which is required when applicable.
From the GraphQL spec: https://facebook.github.io/graphql/#sec-Errors
If an error can be associated to a particular field in the GraphQL result, it must contain an entry with the key
paththat details the path of the response field which experienced the error. This allows clients to identify whether anullresult 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.
...
The response might look like:{ "errors": [ { "message": "Name for character with ID 1002 could not be fetched.", "locations": [ { "line": 6, "column": 7 } ], "path": [ "hero", "heroFriends", 1, "name" ] } ], "data": { "hero": { "name": "R2-D2", "heroFriends": [ { "id": "1000", "name": "Luke Skywalker" }, { "id": "1002", "name": null }, { "id": "1003", "name": "Leia Organa" } ] } } }If the field which experienced an error was declared as Non-Null, the null result will bubble up to the next nullable field. In that case, the path for the error should include the full path to the result field where the error occurred, even if that field is not present in the response.