graphql icon indicating copy to clipboard operation
graphql copied to clipboard

Subscriptions not working properly with Mercurius Federation

Open all2pie opened this issue 3 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behavior

The subscription of individual service works fine directly but it is not working with Federation gateway

Minimum reproduction code

https://github.com/all2pie/Nestjs-Mercurius-Federation-Subscription-Bug

Steps to reproduce

  • npm i
  • nest start service --watch
  • nest start gateway --watch
  • Try this Subscription
    subscription {
      test
    }
    

subscription url: ws://localhost/graphql

Expected behavior

Subscriptions should work correctly

Package version

10.0.10

Graphql version

"@apollo/subgraph": "^0.4.2",
"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",
"@nestjs/graphql": "^10.0.10",
"@nestjs/mercurius": "^10.0.9",
"@nestjs/platform-fastify": "^8.4.4",
"graphql": "^16.4.0",
"mercurius": "^9.3.6",

NestJS version

8.2.2

Node.js version

16.14.0

In which operating systems have you tested?

  • [ ] macOS
  • [X] Windows
  • [ ] Linux

Other

No response

all2pie avatar Apr 28 '22 10:04 all2pie

Same here

Crhis35 avatar Jan 22 '23 21:01 Crhis35

Any update on this issue?

I did some digging and found that the issue is from @apollo/subgraph where subscription fields are not at all being processed to attach subscription resolvers. I have raised an issue on apollo github repository for an answer. So far I have not found any article or document for the reason of subscription fields not being the part of buildSchemaFromSDL since I have build api as a schema first approach. After tweaking buildSchemaFromSDL file I am able to make the feature work.

sushilkjaiswar avatar Feb 20 '23 08:02 sushilkjaiswar

@sushilkjaiswar Could you share the code, please?

asanovr avatar Mar 18 '23 11:03 asanovr