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

feat(gateway): Provide context to didEncounterError for RGDS #600

Merged

Conversation

trevor-scheer
Copy link
Member

This PR introduces a fourth (optional) argument context to the RemoteGraphQLDataSources didEncounterError hook. This is a fairly small, non-breaking change to the API here and it seems fairly reasonable to want access to context from within this hook.

@@ -192,7 +192,8 @@ export class RemoteGraphQLDataSource<TContext extends Record<string, any> = Reco
public didEncounterError(
error: Error,
_fetchRequest: Request,
_fetchResponse?: Response
_fetchResponse?: Response,
_context?: TContext,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a shame that this function doesn't take options (named) arguments but given that it doesn't, this seems like the best change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree - I think it would be nice to move to an options object in a breaking change in the future. Should I open an issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 there are deeper issues with this API (like how the class name sounds like the not really related DataSource and how the method names sound like the AS plugin API) that might be worth addressing at some point

@@ -1,5 +1,5 @@
import { fetch } from '../../__mocks__/apollo-server-env';
import { makeFetchHappenFetcher} from '../../__mocks__/make-fetch-happen-fetcher';
import { makeFetchHappenFetcher } from '../../__mocks__/make-fetch-happen-fetcher';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are those who would complain about applying prettier to a file, but not me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a result of using inline snapshots (which has the effect of prettifying the file when a new snap is printed). I ended up not using a snapshot but the changes persisted. I don't mind either - I'd usually isolate to a commit but hopefully this one was small enough to not be a bother.

@trevor-scheer trevor-scheer changed the base branch from main to release-gateway-0.25.0 March 22, 2021 22:05
@trevor-scheer trevor-scheer force-pushed the trevor/rgds-didEncounterError-context branch from 8c366e2 to 2bfea5f Compare March 22, 2021 22:10
@trevor-scheer trevor-scheer merged commit ee8548d into release-gateway-0.25.0 Mar 22, 2021
@trevor-scheer trevor-scheer deleted the trevor/rgds-didEncounterError-context branch March 22, 2021 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants