apollographql / apollographql/federation

@apollo/gateway: support Plug-n-Play

Open
#301 3 comments 5 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
725
Forks
276
Avg merge
1h 47m
Merged PRs (30d)
1

Description

I get an error using Yarn v2:

```
ERROR in ../.yarn/$$virtual/@apollo-gateway-virtual-e25a4f3da3/0/cache/@apollo-gateway-npm-0.17.0-eab26e86eb-a6b0f134e3.zip/node_modules/@apollo/gateway/dist/loadServicesFromRemoteEndpoint.js
Module not found: Error: @apollo/gateway tried to access node-fetch, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: node-fetch (via "node-fetch")
Required by: @apollo/gateway@virtual:ed56d36c5f6919e62614d755b455368104d720606354e29527d7a3b0d63fbed2697ae5981cf3e0e572ed26b43c40e1704efb4752f3c0fe6a501aa6a4420b4dc4#npm:0.17.0 (via /Users/bchinn/leapyear/leapyear-delta/.yarn/$$virtual/@apollo-gateway-virtual-e25a4f3da3/0/cache/@apollo-gateway-npm-0.17.0-eab26e86eb-a6b0f134e3.zip/node_modules/@apollo/gateway/dist/loadServicesFromRemoteEndpoint.js)
```
Which happens because `@types/node-fetch` is listed as a dependency but not `node-fetch`, even though `node-fetch` is actually needed at runtime, not just for the types (https://github.com/apollographql/federation/blob/a99f9350ffd031056a820f7c6d287e129bc9fd93/gateway-js/src/loadServicesFromRemoteEndpoint.ts#L40).

I'm getting around this by adding the following to `.yarnrc.yml`
```yml
packageExtensions:
'@apollo/gateway@*':
dependencies:
'node-fetch': '*'
```

Contributor guide

Open the contributing guide

Research direction

Start with gateway-js/src/loadServicesFromRemoteEndpoint.ts, where the issue identifies the runtime node-fetch import, then inspect the @apollo/gateway package dependencies. Verify the Yarn v2 Plug'n'Play installation and confirm that the package declares node-fetch and no longer produces the missing-dependency error.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.