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"
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.
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 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.
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)