graphql icon indicating copy to clipboard operation
graphql copied to clipboard

Mercurius Federation Gateway not working

Open all2pie opened this issue 2 years ago • 3 comments

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

all2pie avatar Jul 14 '22 08:07 all2pie

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", ... },

begninix avatar Jul 22 '22 12:07 begninix

Will there be any real fix for this? Because @begninix solution not work.

AmineYagoub avatar Jul 26 '22 10:07 AmineYagoub

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

sushilkjaiswar avatar Sep 13 '22 16:09 sushilkjaiswar

is there any solution for this?? I am facing the same issue 😩

alexandre-dev29 avatar Oct 10 '22 14:10 alexandre-dev29

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.

sushilkjaiswar avatar Oct 10 '22 14:10 sushilkjaiswar

This doesn't seem to be related to NestJS integration packages

kamilmysliwiec avatar Mar 06 '23 07:03 kamilmysliwiec