Need help - Updating the apollo gateway from 0.26.1 to 2.0.0

My current setup:
@apollo/gateway: “0.26.1”
@apollo-server-lambda: “2.22.2”
graphql: 15.5.0

I have updated the gateway to 2.0.0. After deploying I got this exception “TypeError: this.node is not a function” at “apollo/federation-internals/node_modules/@apollo/core-schema/dist/gql.js”.

I got a warning form npm and as well advised in the forum “Federation2 update issue”, I have updated the version of graphql to 16.0.0. This resolved the above mentioned issue. But this time I get an another exception which I mentioned below.

“undefined ERROR (node:16) DeprecationWarning: ‘ApolloGateway.prototype.onSchemaChange’ is deprecated. Use ‘ApolloGateway.prototype.onSchemaLoadOrUpdate’ instead.”

This time I get a warning from the node that this apollo-server-lambda@2.22.2 requires a peer of graphql@^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 but none is installed. Because I have updated the version to 16.0.0

I’m now confused about what went wrong. Do I need to update apollo-server-lambda version too? If so, what is the version.

Yes. Gateway v2 requires graphql@16. Apollo Server v2 supports up to graphql@15, so you’ll need to update to Apollo Server v3.

Thanks so much for the prompt reply. The version conflict issue has been resolved now.

My current setup is
@apollo/gateway: “2.0.0”,
apollo-server-lambda": “^3.0.0”,
“graphql”: “^16.0.0”,

But the existing code setup is not working anymore due to an error occurred during Apollo server startup.

2022-06-24T04:43:12.696Z ERROR An error occurred during Apollo Server startup. All GraphQL requests will now fail. The startup error was: When a manual configuration is not provided, gateway requires an Apollo configuration. See Managed federation overview - Apollo GraphQL Docs for more information. Manual configuration options include: serviceList, supergraphSdl, and `experimental_updateServiceDefinitions

ERROR Invoke Error
{
“errorType”: “Error”,
“errorMessage”: “This data graph is missing a valid configuration. More details may be available in the server logs.”,
“stack”: [
“Error: This data graph is missing a valid configuration. More details may be available in the server logs.”,
" at ApolloServer._ensureStarted (/var/task/node_modules/apollo-server-core/dist/ApolloServer.js:317:27)“,
" at ApolloServer.ensureStarted (/var/task/node_modules/apollo-server-core/dist/ApolloServer.js:331:20)”,
" at /var/task/node_modules/apollo-server-lambda/dist/ApolloServer.js:46:24",
" at Runtime.handler (/var/task/app.js:18:10)“,
" at TransactionShim.applySegment (/opt/nodejs/node_modules/newrelic/lib/shim/shim.js:1430:20)”,
" at Runtime.wrappedHandler (/opt/nodejs/node_modules/newrelic/lib/serverless/aws-lambda.js:188:20)“,
" at TransactionShim.applySegment (/opt/nodejs/node_modules/newrelic/lib/shim/shim.js:1430:20)”,
" at Runtime.transactionWrapper (/opt/nodejs/node_modules/newrelic/lib/shim/transaction-shim.js:621:17)“,
" at Runtime.patchedHandler [as handler] (/opt/nodejs/node_modules/newrelic-lambda-wrapper/index.js:122:25)”,
" at Runtime.handleOnceNonStreaming (/var/runtime/Runtime.js:73:25)"

Please advise.

This tells me that there’s something wrong with your gateway configuration. Are you running managed federation? If you can share a reproduction that would be ideal. If not, can you share all of the code around how you call new ApolloGateway()? Are you providing any environment variables at runtime?

I’m happy to help, but I think that error message is helpful and if you continue down that path you’ll probably find what’s misconfigured. v0.26 to v2 is a rather large jump, a lot has changed in that time.

Hi @trevor.scheer,

The issue is now resolved. Yes, a lot has been changed from 0.26 to 2 and I’m running managed federation.
I have passed the wrong arguments into the apollo server constructor. I got clarified from this doc Migrating to Apollo Server 3 - Apollo GraphQL Docs

Thanks much for your help!

1 Like

Fantastic, thanks for your patience and taking the time to upgrade. We appreciate it (and hope you do too, of course)!

1 Like

Hi @trevor.scheer,
Sorry to bug you again.

I have applied the changes into the existing graph which was developed on the old versions (Federation 1). Getting this issue ERROR.

An error occurred during Apollo Server startup. All GraphQL requests will now fail. The startup error was: ACCESS_DENIED: API key service:XXXXXXX:●●●●●●●●●●●●●●●●●●jlrQ cannot access undefined.
Note: Consumer graph tokens cannot be used for managed federation.

I have also tried with a new API Key but still not working. Please advise.

Nevermind. It’s a small issue with the code. I fixed it. thanks!

1 Like

Can u share have similar issue