apollographql / apollo-link

:link: Interface for fetching and modifying control flow of GraphQL requests
https://www.apollographql.com/docs/link/
MIT License
1.44k stars 344 forks source link

Removed Error type since it blocks the rest from showing up #1270

Open DalerAsrorov opened 4 years ago

DalerAsrorov commented 4 years ago

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.

apollo-cla commented 4 years ago

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