Skip to content
This repository has been archived by the owner on Mar 18, 2020. It is now read-only.

Apollo Federation support for NextJS GraphQL module. Note: There is support for federation in the official package now so this project is deprecated

License

Notifications You must be signed in to change notification settings

juicycleff/nestjs-graphql-gateway

Repository files navigation

NestJs GraphQL Gateway (supports type-graphql)

NestJS GraphQL Apollo Federation extension. You keep using @nestjs/graphql for all other steps

NPM Version License Code Size Top Language Top Language

Installation

$ yarn install nestjs-graphql-gateway

Setup federated service

import { Module } from '@nestjs/common';
import { GraphqlDistributedModule } from 'nestjs-graphql-gateway';

@Module({
  imports: [
    GraphqlDistributedModule.forRoot({
      typePaths: [path.join(process.cwd() + '/apps/service-auth/src', '/**/*.graphql')],
      introspection: true,
      playground: {
        workspaceName: 'GRAPHQL CQRS',
        settings: {
          'editor.theme': 'light',
        },
      },
      context: (ctx) => ctx,
    })
  ]
})
export class AppModule {}


// Code first TypegraphQl

@Module({
  imports: [
    GraphqlDistributedModule.forRoot({
      autoSchemaFile: 'graphs/demo.gql',
      
      // optional orphaned types
      buildSchemaOptions: {
        orphanedTypes: [Tenant, TenantMember, User],
      },
      
      context: (ctx) => ctx,
    })
  ]
})
export class AppModule {}

Setup Gateway

import { Module } from '@nestjs/common';
import { GraphqlDistributedGatewayModule } from 'nestjs-graphql-gateway';

@Module({
  imports: [
    GraphqlDistributedGatewayModule.forRoot({
      subscriptions: false,
      path: '/graphql',
      context: context => context,
      serviceList: [
        { name: 'auth', url: 'http://localhost:1000/graphql' },
        { name: 'user', url: 'http://localhost:2000/graphql' },
        // more services
      ],
      buildService({ url }) {
        return new HeadersDatasource({ url });
      },
    }),
  ]
})
export class AppModule {}

License

This project is MIT licensed.

About

Apollo Federation support for NextJS GraphQL module. Note: There is support for federation in the official package now so this project is deprecated

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published