Skip to content

Commit

Permalink
docs: example response of unauth fields for requiresScopes (#4742)
Browse files Browse the repository at this point in the history
Co-authored-by: Maria Elisabeth Schreiber <maria.schreiber@apollographql.com>
Co-authored-by: Geoffroy Couprie <apollo@geoffroycouprie.com>
  • Loading branch information
3 people committed Mar 7, 2024
1 parent a2ad99d commit 986d664
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions docs/source/configuration/authorization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,40 @@ query {
The response would include an error at the `/users/@/email` path since that field requires the `read:emails` scope.
The router can execute the entire query successfully if the request includes the `read:others read:emails` scope set.

The router returns `null` for unauthorized fields and applies the [standard GraphQL null propagation rules](https://www.apollographql.com/blog/graphql/basics/using-nullability-in-graphql/#what-happens-if-you-try-to-return-null-for-a-non-null-field).

```json title="Unauthorized request response"
{
"data": {
"me": null,
"post": {
"title": "Securing supergraphs",
}
},
"errors": [
{
"message": "Unauthorized field or type",
"path": [
"me"
],
"extensions": {
"code": "UNAUTHORIZED_FIELD_OR_TYPE"
}
},
{
"message": "Unauthorized field or type",
"path": [
"post",
"views"
],
"extensions": {
"code": "UNAUTHORIZED_FIELD_OR_TYPE"
}
}
]
}
```

<MinVersion version="1.29.1">

### `@authenticated`
Expand Down

0 comments on commit 986d664

Please sign in to comment.