graphql
graphql copied to clipboard
Mercurius Federation Gateway not working
Did you read the migration guide?
- [X] I have read the whole migration guide
Is there an existing issue that is already proposing this?
- [X] I have searched the existing issues
Potential Commit/PR that introduced the regression
No response
Versions
8.0.0 -> 9.0.3
Describe the regression
After upgrading the Nestjs to V9 the Federation Gateway stopped working and is giving this error:
mercurius-fedration-gateway-bug-nestjs\node_modules\graphql\error\syntaxError.js:15
return new _GraphQLError.GraphQLError(`Syntax Error: ${description}`, {
^
GraphQLError: Syntax Error: Unexpected Name "on".
at syntaxError (C:\Work\Bugs\mercurius-fedration-gateway-bug-nestjs\node_modules\graphql\error\syntaxError.js:15:10)
at Parser.unexpected (C:\Work\Bugs\mercurius-fedration-gateway-bug-nestjs\node_modules\graphql\language\parser.js:1476:41)
at Parser.parseDefinition (C:\Work\Bugs\mercurius-fedration-gateway-bug-nestjs\node_modules\graphql\language\parser.js:211:16)
at Parser.many (C:\Work\Bugs\mercurius-fedration-gateway-bug-nestjs\node_modules\graphql\language\parser.js:1529:26)
at Parser.parseDocument (C:\Work\Bugs\mercurius-fedration-gateway-bug-nestjs\node_modules\graphql\language\parser.js:121:25)
at parse (C:\Work\Bugs\mercurius-fedration-gateway-bug-nestjs\node_modules\graphql\language\parser.js:32:17)
at buildFederationSchema (C:\Work\Bugs\mercurius-fedration-gateway-bug-nestjs\node_modules\mercurius\lib\federation.js:279:32)
at buildGateway (C:\Work\Bugs\mercurius-fedration-gateway-bug-nestjs\node_modules\mercurius\lib\gateway.js:316:18)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at fp.name (C:\Work\Bugs\mercurius-fedration-gateway-bug-nestjs\node_modules\mercurius\index.js:233:15)
It works fine if there is only single service in the services array in gateway.module.ts
, but its giving the above error with multiple services
Minimum reproduction code
https://github.com/all2pie/nestjs-mercurius-fedration-gateway-issue
Expected behavior
The gateway should work fine
Other
No response
You can fix this problem by setting the version of @apollo/subgraph in your services package.json to 2.0.2.
"dependencies": { "@apollo/subgraph": "2.0.2", ... },
Will there be any real fix for this? Because @begninix solution not work.
Will there be any real fix for this? Because @begninix solution not work.
Do you have any solution for this issue ? I am facing same issue and where federation with more than one service throws syntax error "Syntax Error: Unexpected "@". Single service works fine with federation when using Mercurius with Nestjs
is there any solution for this?? I am facing the same issue 😩
is there any solution for this?? I am facing the same issue 😩
I did manage to pass all issues and was able to run the server successfully. I had to fix the schema(I use schema first approach) and updated Mercurius federation lib to fix the issue. Still not sure if the solution will be accepted by Mercurius author.
This doesn't seem to be related to NestJS integration packages