Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align GraphQLErrors and NetworkError errors. Fix docs #8950

Closed
wants to merge 1 commit into from
Closed

Align GraphQLErrors and NetworkError errors. Fix docs #8950

wants to merge 1 commit into from

Conversation

korywka
Copy link
Contributor

@korywka korywka commented Oct 20, 2021

  1. Continue to align error types according to changes in Align NetworkError and GraphQLErrors types #8424

  2. Try to fix Typescript error when ignoring errors #8896

const errorLink = onError(({ response, operation }) => {
  if (operation.operationName === "IgnoreErrorsQuery") {
    response.errors = null;
  }
});

The error is:

Type 'null' is not assignable to type 'readonly GraphQLError[] | undefined'

If we look at ExecutionResult types at graphql, errors can't be null:

image

https://github.com/graphql/graphql-js/blob/e289e6412ca59cd6298796d61efa19d78eeb945c/src/execution/execute.ts#L127-L134

So I suggest to fix docs to assign undefined instead of null.

Also we need to check if response exists, cause it is optional:

export interface ErrorResponse {
graphQLErrors?: ReadonlyArray<GraphQLError>;
networkError?: Error | ServerError | ServerParseError;
response?: ExecutionResult;
operation: Operation;
forward: NextLink;
}

So my suggestion is to check like this:

if (response && operation.operationName === "IgnoreErrorsQuery") {
  response.errors = undefined;
}

The bad part is that a lot of tests are broken in this rc:

Test Suites: 93 failed, 18 passed, 111 total

I could not brake them 🤷‍♂️. So please, verify these changes and merge them on your own risk. Thanks!

@korywka
Copy link
Contributor Author

korywka commented Nov 8, 2021

@StephenBarlow @brainkim Please let me know if you are interested in this PR and I will resolve conflicts.

@korywka korywka closed this Nov 24, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant