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

[RESTDataSource] refactor to allow overridding the Error class #3878

Closed

Conversation

eturino
Copy link

@eturino eturino commented Mar 10, 2020

for example if we want to create a NotFoundError that will be used when receiving 404s. This way we need to override the bare minimum like

class MyDataSource extends RESTDataSource {
  protected errorBaseFromResponseAndMessage(response: Response, message: string): ApolloError {
    if (response.status === 401) return new NotFoundError(message);

    return super.errorBaseFromResponseAndMessage(response, message);
  }
}

Also adding it in the RemoteGraphQLDataSource since it has the same code as RESTDataSource, for symmetry purposes.

for example if we want to create a `NotFoundError` that will be used when receiving 404s. This way we need to override the bare minimum like

```
class MyDataSource extends RESTDataSource {
  protected errorBaseFromResponseAndMessage(response: Response, message: string): ApolloError {
    if (response.status === 401) return new NotFoundError(message);

    return super.errorBaseFromResponseAndMessage(response, message);
  }
}
```

Also adding it in the RemoteGraphQLDataSource since it has the same code as RESTDataSource, for symmetry purposes.

Signed-off-by: Eduardo Turiño <[email protected]>
@abernix abernix closed this Jun 24, 2020
@eturino
Copy link
Author

eturino commented Jun 25, 2020

@abernix can I ask the reason for closing it? Is there anything I can do to help get it along?

@eturino
Copy link
Author

eturino commented Jun 25, 2020

Ah! I just saw the comment at the end of #4302
I can reopen it.

@abernix
Copy link
Member

abernix commented Jun 25, 2020

Okay, so the automated process was able to re-open all but five of the PRs, and this was one of them. Reason being (from the GitHub interface): The branch was force-pushed or recreated.

So I could have re-opened this, but since you opened a new one, that one has to be re-opened instead. 🤷

All good! I'll re-open the other one (which I already closed). Sorry for the noise!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 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.

2 participants