2.0.9 • Published 4 years ago

@yolkai/nestjs-graphql-gateway v2.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

NestJs GraphQL Gateway (supports type-graphql)

Why?

This fork was created to provide an instance of this library that removes the temp__ property from the Query fields as it is no longer required. This fork enables the consumer to federate multiple services, without this the temp__ field with collide preventing services from booting.

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.

2.0.7

4 years ago

2.0.9

4 years ago

2.0.8

4 years ago

2.0.7-alpha.1

4 years ago

2.0.7-alpha.0

4 years ago

2.0.7-0

4 years ago

2.0.5

4 years ago

2.0.6

4 years ago

2.0.4

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago