Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Update link-error docs to reference response.errors = undefined (#1240
Browse files Browse the repository at this point in the history
)

The docs incorrectly show that `response.error` can be null. However in the graphql-js package that defines `ExecutiionResult` in is is either an array of `GraphQLError` or undefined. Null is not a valid option.

https://github.com/graphql/graphql-js/blob/master/src/execution/execute.d.ts#L52
  • Loading branch information
dangreenisrael authored Jan 31, 2020
1 parent f3dcc8b commit d56fce6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/apollo-link-error/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ One caveat is that the errors from the new response from retrying the request do

## Ignoring errors

If you want to conditionally ignore errors, you can set `response.errors = null;` within the error handler:
If you want to conditionally ignore errors, you can set `response.errors = undefined;` within the error handler:

```js
onError(({ response, operation }) => {
if (operation.operationName === "IgnoreErrorsQuery") {
response.errors = null;
response.errors = undefined;
}
});
```
4 changes: 2 additions & 2 deletions packages/apollo-link-error/src/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('error handling', () => {
const errorLink = onError(({ graphQLErrors, response }) => {
expect(graphQLErrors[0].message).toBe('ignore');
// ignore errors
response.errors = null;
response.errors = undefined;
called = true;
});

Expand All @@ -188,7 +188,7 @@ describe('error handling', () => {

execute(link, { query }).subscribe({
next: ({ errors, data }) => {
expect(errors).toBe(null);
expect(errors).toBe(undefined);
expect(data).toEqual({ foo: { id: 1 } });
},
complete: done,
Expand Down

0 comments on commit d56fce6

Please sign in to comment.