-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Allow overriding URL/method in RemoteGraphQLDataSource #5514
Conversation
@Cretezy: 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/ |
This seems reasonable, but even better would be eliminating our own hand-coded copies of the |
@glasser I'd be fine with that too. I can help with reviews/testing if needed. Just want to get this fixed so I can avoid |
@abernix It seems like the options are:
|
This seems like the opposite direction than what we've been trying to move in since
Seems somewhat reasonable for the properties to not be Or |
Hmm, @abernix, that seems attractive but it looks like the Request API annoyingly doesn't have an API for "copy this Request but with a different url"? clone takes no arguments, and you can provide a Request to the Request constructor but only in the same spot as the url! We could just add some sort of getUrl({ request, context }) to RemoteGraphQLDataSource... |
I think that moving our TS types farther away from the actual Fetch API isn't a good idea. I'm going to transfer this issue to the federation repo and suggest we think of it as a suggestion for providing an overridable hook to provide the URL/request per-request. eg, we could extract out
into something like
which you can override as you'd like. (Note that #870 adds an option to |
Or well, this is a PR, so I'm going to close this and open an issue there. |
I'm currently attempting to override the fetched URL/method in
RemoteGraphQLDataSource
. Although it's possible with a custom fetcher, it really should be easier.I'm currently attempting to do something like:
However, due to the
readonly
modifier onRequest.url
, this is impossible, even though it would work as per the code.method
should also work the same.From what I can see by a brief look, this would not affect any other parts of the application (plus, it is a type-only change).