apollographql / federation-demo

Federation 2 supersedes this demo and this example is no longer the newest. See https://www.apollographql.com/docs/federation/ for migration steps!
https://www.apollographql.com/docs/federation/
MIT License
502 stars 200 forks source link

Demo does not work with latest Apollo Server Version #63

Closed vany0114 closed 2 years ago

vany0114 commented 2 years ago

Hi guys, not sure if you're aware of this issue.

I was migrating my gateway implementation to Apollo Server 3.* so started by migrating its graphql endpoints (all good there) but when I was migrating the gateway I realized that it throws an error at runtime:

UnhandledPromiseRejectionWarning: TypeError: Object.values(...).filter(...).flatMap is not a function
[start-service-accounts]     at Object.serverWillStart (C:\Users\vany0\OneDrive\Documentos\GitHub\apollo-client-cache-issue\federation-demo\services\accounts\node_modules\apollo-server-core\dist\plugin\cacheControl\index.js:40:22)
[start-service-accounts]     at Promise.all.plugins.map (C:\Users\vany0\OneDrive\Documentos\GitHub\apollo-client-cache-issue\federation-demo\services\accounts\node_modules\apollo-server-core\dist\ApolloServer.js:176:73)
[start-service-accounts]     at Array.map (<anonymous>)
[start-service-accounts]     at ApolloServer._start (C:\Users\vany0\OneDrive\Documentos\GitHub\apollo-client-cache-issue\federation-demo\services\accounts\node_modules\apollo-server-core\dist\ApolloServer.js:175:75)[start-service-accounts]     at ApolloServer.listen (C:\Users\vany0\OneDrive\Documentos\GitHub\apollo-client-cache-issue\federation-demo\services\accounts\node_modules\apollo-server\dist\index.js:56:20)
[start-service-accounts]     at Object.<anonymous> (C:\Users\vany0\OneDrive\Documentos\GitHub\apollo-client-cache-issue\federation-demo\services\accounts\index.js:38:8)
[start-service-accounts]     at Module._compile (internal/modules/cjs/loader.js:778:30)
[start-service-accounts]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
[start-service-accounts]     at Module.load (internal/modules/cjs/loader.js:653:32)
[start-service-accounts]     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
[start-service-accounts] (node:22488) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

Basically, it is throwing the error here

I had a rough time trying to make it work w/o any luck, so I had to go undo the changes in the gateway and go back to use apollo-server 2.* these are the dependencies I'm using in the gateway:

"@apollo/federation": "0.20.4",
"@apollo/gateway": "0.21.1",
"apollo-server": "^2.19.0",

So by using those dependencies I was able to run the gateway with its endpoints using apollo server 3.*

Any ideas?

dnalborczyk commented 2 years ago

@vany0114 you need to bump your node.js version to v12 or higher.

https://www.apollographql.com/blog/announcement/backend/its-here-introducing-apollo-server-3/

We’ve dropped support for Node 8 and 10 (which are no longer in LTS), which lets the TypeScript compiler output more efficient code that takes advantage of newer Node features.