-
Notifications
You must be signed in to change notification settings - Fork 254
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 runtime dependency on node-fetch #1970
Conversation
We do use `node-fetch` during runtime for some of the public methods in `RemoteGraphQLDataSource`. Using `node-fetch@2` because v3 is ESM-only. There's already a renovate rule to keep things from going to v3. We should probably break the interfaces that are using `node-fetch`'s classes, since they aren't used by the default implementation after switching to `make-fetch-happen`. ### Other detritus - **Move `@types/node-fetch` to `devDependencies`** This was originally included in apollographql/apollo-server#3546 as a fix for apollographql/apollo-server#3471. I think this is more appropriate for types. - **Change some imports to use `type`** so there's no runtime dependency for things that are just using types. - **Add `@types/make-fetch-happen`** - **Remove `pretty-format`** since that's not a runtime thing Fixes #1961
✅ Deploy Preview for apollo-federation-docs canceled.
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
That doesn't make a ton of sense to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree the dependency appears to be required currently because we literally use new Headers
to pass in the headers to the fetch implementation.
That said, am curious if we could opt to just pass a plain object as headers
rather than a Headers
. It's my understanding that most fetch
implementations will accept merely an object, and the Fetch API specification suggests that it's completely fine to do so. Is that worth a consideration?
Anyhow, just a thought. LGTM, but also like the idea of not including the dependency at all if we can avoid it.
I like this line of thinking and I tried but got hung up on some type conflicts that were buried a bit too far. Lemme dig those up so we can talk specifics, instead of this hand-wavy response I've got so far. |
I missed this part of the comment earlier. We also use federation/gateway-js/src/datasources/RemoteGraphQLDataSource.ts Lines 196 to 201 in 8c4ecd6
new Headers , we'll still have that interface to support.
That said... We use this type declaration for headers for all of our TL;DRRemoving |
#1970 seems to have caused a regression based on `@types/node-fetch` not being in the gateway's runtime dependencies
We use
node-fetch
during runtime for some of the public methods inRemoteGraphQLDataSource
. Usingnode-fetch@2
because v3 is ESM-only. There's already a renovate rule to keep things from going to v3.We should probably break the interfaces that are using
node-fetch
's classes, since they aren't used by the default implementation after switching tomake-fetch-happen
.Other detritus
@types/node-fetch
This was originally included in Add production dependency on@types/node-fetch
. apollo-server#3546 as a fix for @apollo/gateway doesn't include node-fetch in its dependencies apollo-server#3471.type
so there's no runtime dependency for things that are just using types.pretty-format
since that's not a runtime thingFixes #1961
TODO
Headers
object