dotansimha / graphql-yoga

🧘 Rewrite of a fully-featured GraphQL Server with focus on easy setup, performance & great developer experience. The core of Yoga implements WHATWG Fetch API and can run/deploy on any JS environment.
https://the-guild.dev/graphql/yoga-server
MIT License
8.25k stars 574 forks source link

Support subscription for Nest.js Federation driver #2965

Closed vasily-polonsky closed 1 year ago

vasily-polonsky commented 1 year ago

Is your feature request related to a problem? Please describe.

I am using Graphql Mesh + Graphql-Yoga with nest.js Wanted to use subscriptions, for real time events. But faced this error Error: No support for subscriptions when using Apollo Federation.

I found in the guild documentation that If I want to use Subscriptions with a Federated Gateway I should use Schema Stitching. As mesh uses schema stitching it should work. https://the-guild.dev/graphql/yoga-server/docs/features/apollo-federation

The problem is that subgraphs with apollo federation do not support subscriptions. And if I launch YogaDriver for nestjs, it doesnt support graphql federation syntax with @keys, @external, etc

Describe the solution you'd like

As recently apollo federation added support for subscriptions, tried to enable subscriptions but there is a check in the federation driver, but it has no effect. Maybe I did smt wrong, but should be as apollo-subgraph should support subscriptions now

Another solution would be to support graphql federation syntax for YogaDriver, but looks like a hacky solution

vasily-polonsky commented 1 year ago

created a PR https://github.com/dotansimha/graphql-yoga/pull/2966 As @apollo/subgraph version is already 2.4.0, worked for me without updating dependencies

btw, subscriptions from @graphql-mesh are also working

ardatan commented 1 year ago

Thanks for the PR! It's merged and available with the latest release!