apollo-link icon indicating copy to clipboard operation
apollo-link copied to clipboard

Removed Error type since it blocks the rest from showing up

Open DalerAsrorov opened this issue 4 years ago • 1 comments

While going over the apollo link example in https://www.apollographql.com/docs/link/links/context/,

  if (networkError && networkError.name ==='ServerError' && networkError.statusCode === 401) {
    // remove cached token on 401 from the server
    token = null;
  }

the statusCode property wasn't recognized in my editor: Screen Shot 2020-05-02 at 12 39 22 AM

I believe since both ServerError and ServerParseError already include Error with & operator:

export declare type ServerError = Error & {
    response: Response;
    result: Record<string, any>;
    statusCode: number;
};

export declare type ServerParseError = Error & {
    response: Response;
    statusCode: number;
    bodyText: string;
};

it should make sense to remove it. The TS lint error disappears and allows me to see the valid contents of the error.

  • [x] Make sure all of new logic is covered by tests and passes linting
  • [x] Update CHANGELOG.md with your change

DalerAsrorov avatar May 02 '20 06:05 DalerAsrorov

@DalerAsrorov: 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/

apollo-cla avatar May 02 '20 06:05 apollo-cla