-
Notifications
You must be signed in to change notification settings - Fork 257
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
node-fetch runtime dependency is missing in @apollo/gateway v2.0.5 #1961
Comments
howdy @marcelkottmann! Are you able to share the package file (at least the dependencies) and which package manager is being used? Can you also share more of the stacktrace, specifically the line the error is coming from?
I agree about this, it should be moved over to Doing some minimal setup seems to work OK https://stackblitz.com/edit/apollo-basic-fed-demo-twdpoe?file=package.json, though I realize that's probably not very helpful since it's not upgrading from a previous version. |
Hi @benweatherman , I have no lines in the stack trace but I guess its node_modules/@apollo/gateway/dist/executeQueryPlan.js:4 because there is this line
So basically you are using node-fetch in your code, without declaring it as a production dependency. We use "@apollo/gateway": "2.0.5",
"apollo-server": "3.9.0",
"apollo-server-cache-redis": "3.3.1",
"apollo-server-caching": "3.3.0",
"apollo-server-core": "3.9.0",
"apollo-server-express": "3.9.0",
"apollo-server-lambda": "3.9.0",
"apollo-server-plugin-base": "3.6.1",
"apollo-server-plugin-response-cache": "3.6.1",
"apollo-server-types": "3.6.1",
"graphql": "16.5.0", Your test project you linked is not using |
Thanks for the extra info @marcelkottmann! Not sure how I missed these before but we import
Not sure yet if should be importing those from somewhere else or if we should add the runtime dependency to |
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
We are currently upgrading our application to Federation v2. After upgrading the necessary packages, we found out that node-fetch is a runtime dependency of @apollo/gateway (current, v2.0.5) and is missing in its package.json.
We therefore get a runtime error:
Error: Cannot find module 'node-fetch' Require stack: - /var/task/node_modules/@apollo/gateway/dist/executeQueryPlan.js - /var/task/node_modules/@apollo/gateway/dist/index.js
Strange enough the only node-fetch related thing in the package.json are the typings of node-fetch
@types/node-fetch
which is sorted into thedependencies
, although typing packages typically are listed in thedevDependencies
-section.See https://github.com/apollographql/federation/blob/%40apollo/gateway%402.0.5/gateway-js/package.json
Adding node-fetch@2.6.7 as a dependency in our projects
package.json
fixed this problem for us, but is considered a workaround, because our codebase does not usenode-fetch
.The text was updated successfully, but these errors were encountered: