Federation2 update issue

Hello Everyone,
I am upgrading apollo gateway from “@apollo/gateway”: “0.44.1”, to “@apollo/gateway”: “^2.0.4”. while upgradation I am facing issue in core-schema which is internally used by federation internal.

"return this.node<DefinitionNode>(this._lexer.token, {
                  ^
TypeError: this.node is not a function"

I have only update the gateway.

any help would be thankful.

2 Likes

@IamSKM can you share a reproduction that we can clone?

My current setup
@apollo/federation”: “0.29.0”,
@apollo/gateway”: “0.44.1”,
“graphql”: “15.5.1”,

I have also added managed supergraph. But when I am running this command yarn add @apollo/gateway to add latest gateway, issue with core-schema is appearing.

I can give you snapshot of error as well.

Thanks in advance for helping me.

Howdy @IamSKM!

Sorry about the troubles with the upgrade. It seems like the error is likely coming from this part of core-schema-js core-schema-js/gql.ts at 72fd6aed8d52f75c6cdaaf274dc07d991d5bf7c5 · apollographql/core-schema-js · GitHub. Is that right?

Is that library being used to explicitly parse a schema? As @trevor.scheer mentioned, it would also be nice to see more steps to reproduce the issue. Are you able to give us a snippet of the code that’s causing the error? The schema being used would also be helpful.

A few unrelated notes:

  • You likely don’t want to use @apollo/federation any longer. Depending on what it’s being used for, we can suggest some alternatives.
  • @apollo/gateway@2.0.x requires graphql >= 16.0.0, so that will need to be updated as well.

Thanks!

@weatherman Thanks for your reply.

I am following these steps Moving to Apollo Federation 2 - Apollo GraphQL Docs

during first step I am getting error. I have also updated the graphql version to 16 as well but it seems issue is still exist.

here is screenshot where we are getting this issue.

Thanks for getting back with more info. That screenshot is showing the underlying core-schema-js code that’s causing the exception you’re seeing. If you’re able to show your code where the error is originating, or a smaller sample that reproduces the issue, it’ll be a little easier to diagnose.

I believe you’re seeing the error because somewhere in your code you’re importing gql from core-schema-js. Instead, you should be importing that from graphql-tag or apollo-server.

Hi, I am getting the similar error:

19	return this.node(this._lexer.token, {
20	^
21	TypeError: this.node is not a function
22	at Parser.parseDefinition (/home/app/folder_name/graphql_gateway/node_modules/@apollo/core-schema/dist/gql.js:17:25)
23	at Parser.many (/home/app/folder_name/graphql_gateway/node_modules/graphql/language/parser.js:1523:26)
24	at Parser.parseDocument (/home/app/folder_name/graphql_gateway/node_modules/graphql/language/parser.js:115:25)
25	at gql (/home/app/folder_name/graphql_gateway/node_modules/@apollo/core-schema/dist/gql.js:10:19)
26	at Object.<anonymous> (/home/app/folder_name/graphql_gateway/node_modules/@apollo/core-schema/dist/linker.js:326:93)
27	at Module._compile (node:internal/modules/cjs/loader:1101:14)
28	at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
29	at Module.load (node:internal/modules/cjs/loader:981:32)
30	at Function.Module._load (node:internal/modules/cjs/loader:822:12)
31	at Module.require (node:internal/modules/cjs/loader:1005:19)

Upgrading to graphql 16 fixed the given error.