Enable GraphQL subscriptions on Apollo Gateway server

184 Views Asked by At

I have a nestjs GraphQL Federation microservices app that uses federation gateway. here's the code for the gateway module;

import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { ApolloGatewayDriver, ApolloGatewayDriverConfig } from '@nestjs/apollo';
import { IntrospectAndCompose } from '@apollo/gateway';
import { GraphQLDataSource } from './graphql-data-source';

@Module({
  imports: [
    GraphQLModule.forRoot<ApolloGatewayDriverConfig>({
      driver: ApolloGatewayDriver,
      gateway: {
        buildService: (args) => new GraphQLDataSource(args),
        supergraphSdl: new IntrospectAndCompose({
          subgraphs: [
            {
              name: 'users',
              url: 'http://localhost:9009/graphql',
            },
            {
              name: 'posts',
              url: 'http://localhost:9119/graphql',
            },
            {
              name: 'comments',
              url: 'http://localhost:9229/graphql',
            },
            {
              name: 'klads',
              url: 'http://localhost:9339/graphql',
            },
            // {
            //   name: 'mailer',
            //   url: 'http://localhost:9449/graphql',
            // },
            // {
            //   name: 'notification',
            //   url: 'http://localhost:9559/graphql',
            // },
          ],
        }),
      },
    }),
  ],
})
export class GatewayModule {}


the posts microservices exposes subscriptions that are working on posts port, but i can't get it to working on the gateway and i can't find how to enable subscriptions on the gateway server as there is no subscriptions option with the gateway driver.

0

There are 0 best solutions below