Skip to content

Commit

Permalink
docs(format-error): add an explanation that the original error wrappe…
Browse files Browse the repository at this point in the history
…d in GraphQLError (#7443)
  • Loading branch information
denis-bel committed Mar 14, 2023
1 parent 4668f45 commit 074d3d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/source/api/apollo-server.mdx
Expand Up @@ -293,7 +293,7 @@ You can disable this recommended security feature by passing `false` to `csrfPre

Provide this function to transform the structure of error objects before they're sent to a client.

The `formatError` hook receives two arguments: the first is a [`GraphQLFormattedError`](https://github.com/graphql/graphql-js/blob/29bf39faa670effd3c1561a1512ec7767658a63b/src/error/GraphQLError.ts#L215) (to be spent with the response), and the second is the original error. This function should return a [`GraphQLFormattedError`](https://github.com/graphql/graphql-js/blob/29bf39faa670effd3c1561a1512ec7767658a63b/src/error/GraphQLError.ts#L215) object.
The `formatError` hook receives two arguments: the first is a [`GraphQLFormattedError`](https://github.com/graphql/graphql-js/blob/29bf39faa670effd3c1561a1512ec7767658a63b/src/error/GraphQLError.ts#L215) (to be spent with the response), and the second is the original error [(wrapped in GraphQLError if thrown by a resolver)](/docs/source/data/errors.mdx#for-client-responses). This function should return a [`GraphQLFormattedError`](https://github.com/graphql/graphql-js/blob/29bf39faa670effd3c1561a1512ec7767658a63b/src/error/GraphQLError.ts#L215) object.

</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion docs/source/data/errors.mdx
Expand Up @@ -345,7 +345,7 @@ You can edit Apollo Server error details before they're passed to a client or re

The `ApolloServer` constructor accepts a `formatError` hook that is run on each error before it's passed back to the client. You can use this function to log or mask particular errors.

The `formatError` hook receives two arguments: the first is the error formatted as a JSON object (to be sent with the response), and the second is the original error.
The `formatError` hook receives two arguments: the first is the error formatted as a JSON object (to be sent with the response), and the second is the original error (wrapped in `GraphQLError` if thrown by a resolver).

> The `formatError` function does _not_ modify errors that are sent to Apollo Studio as part of usage reporting. See [For Apollo Studio reporting](#for-apollo-studio-reporting).
Expand Down

0 comments on commit 074d3d7

Please sign in to comment.