Skip to content

Commit

Permalink
docs (20.11.1): Add docs about how errors are returned from custom en…
Browse files Browse the repository at this point in the history
…dpoints (#7290) (#7320)
  • Loading branch information
bucanero committed Jan 15, 2021
1 parent 042e487 commit b70a4a7
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions wiki/content/graphql/custom/directive.md
Expand Up @@ -308,6 +308,33 @@ then Dgraph expects a GraphQL call to `post` to return a valid GraphQL result li

Similarly, Dgraph expects `postByAuthor` to return data like `{ "data": { "postByAuthor": [ {...}, ... ] } }` and will use the array value of `postByAuthor` to build its array of posts result.

## How errors from custom endpoints are handled

When a query returns an error while resolving from a custom HTTP endpoint, the error is added to the `errors` array and sent back to the user in the JSON response.

When a field returns an error while resolving a custom HTTP endpoint, the field's value becomes `null` and the error is added to the `errors` JSON array. The rest of the fields are still resolved as required by the request.

For example, a query from a custom HTTP endpoint will return an error in the following format:

```json
{
"errors": [
{
"message": "Rest API returns Error for myFavoriteMovies query",
"locations": [
{
"line": 5,
"column": 4
}
],
"path": [
"Movies",
"name"
]
}
]
}
```

## How custom fields are resolved

Expand Down

0 comments on commit b70a4a7

Please sign in to comment.