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

Add url as an argument to the RESTDataSource.didEncounterError() function #238

Closed
HishamAli81 opened this issue Aug 11, 2023 · 0 comments · Fixed by #242
Closed

Add url as an argument to the RESTDataSource.didEncounterError() function #238

HishamAli81 opened this issue Aug 11, 2023 · 0 comments · Fixed by #242

Comments

@HishamAli81
Copy link
Contributor

HishamAli81 commented Aug 11, 2023

Problem:

Currently, the RESTDataSource.didEncounterError() function accepts the error and request options argument: https://github.com/apollographql/datasource-rest/blob/main/src/RESTDataSource.ts#L264C3-L269C4

But since RequestOptions doesn't include either the request path or url, we don't have access to the entire request info that was sent. The path/url would be useful for logging and debugging potential failures.

NOTE: In the old apollo-datasource-rest implementation, Request was passed in as an argument instead of RequestOptions which included the url field:

protected didEncounterError(error: Error, _request: Request) {
    throw error;
}

Proposal:

Update the RESTDataSource.didEncounterError() function to include an url argument:

protected didEncounterError(_error: Error, _url: string, _request: RequestOptions) {
    // left as a no-op instead of an unimplemented optional method to avoid
    // breaking an existing use case where one calls
    // `super.didEncounterErrors(...)` This could be unimplemented / undefined
    // in a theoretical next major of this package.
 }

Which is also consistent with the arguments passed into the RESTDataSource.cacheOptionsFor() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant