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 NetworkError and GraphQLErrors types #8424

Merged
merged 1 commit into from
Sep 28, 2021
Merged

Align NetworkError and GraphQLErrors types #8424

merged 1 commit into from
Sep 28, 2021

Conversation

korywka
Copy link
Contributor

@korywka korywka commented Jun 24, 2021

The problem:

Application-wide networkError error handler fails with error:

TS2322: Type 'Error | ServerParseError | ServerError | null' is not assignable to type 'Error | ServerParseError | ServerError | undefined'.   Type 'null' is not assignable to type 'Error | ServerParseError | ServerError | undefined'. 

Seems to be due to:

ApolloError networkError have Error | ServerParseError | ServerError | null type:

export declare class ApolloError extends Error {
    message: string;
    graphQLErrors: ReadonlyArray<GraphQLError>;
    networkError: Error | ServerParseError | ServerError | null;

But the same networkError in ErrorResponse have Error | ServerError | ServerParseError type:

export interface ErrorResponse {
    graphQLErrors?: ReadonlyArray<GraphQLError>;
    networkError?: Error | ServerError | ServerParseError;

The difference is in null. To keep backward compatibility as much as possible, I am adding null to Link ErrorResponse interface.

The next step may be to remove null and make it optional.

@apollo-cla
Copy link

@korywka: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@brainkim brainkim added this to the July 2021 milestone Jul 6, 2021
@hwillson hwillson removed this from the MM-2021-07 milestone Jul 29, 2021
@hwillson hwillson added 2021-08 and removed 2021-07 labels Aug 3, 2021
@hwillson hwillson added 2021-09 and removed 2021-08 labels Sep 7, 2021
@hwillson hwillson changed the base branch from main to release-3.5 September 28, 2021 18:37
@hwillson hwillson added this to the Release 3.5 milestone Sep 28, 2021
@brainkim brainkim merged commit 27f2f80 into apollographql:release-3.5 Sep 28, 2021
@brainkim
Copy link
Contributor

brainkim commented Oct 5, 2021

Thanks again @korywka!

@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants