From cbc79a47ca2f9525d1f352350be957cd0e37ee7c Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 5 Mar 2025 18:14:37 +0300 Subject: [PATCH] Docs/Gateway: NestJS integration (#6545) Co-authored-by: Denis Badurina Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../deployment/node-frameworks/nestjs.mdx | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 packages/web/docs/src/content/gateway/deployment/node-frameworks/nestjs.mdx diff --git a/packages/web/docs/src/content/gateway/deployment/node-frameworks/nestjs.mdx b/packages/web/docs/src/content/gateway/deployment/node-frameworks/nestjs.mdx new file mode 100644 index 000000000..c8409702d --- /dev/null +++ b/packages/web/docs/src/content/gateway/deployment/node-frameworks/nestjs.mdx @@ -0,0 +1,60 @@ +--- +description: + Hive Gateway Driver for Nest (Nest JS) is a Node.js framework for building server-side + applications. +--- + +import { Callout } from '@theguild/components' + +# Integration with NestJS + +[Nest (Nest JS)](https://nestjs.com) is a progressive Node.js framework for building efficient, +reliable and scalable server-side applications. + +Hive Gateway provides its own Nest GraphQL Driver that supports building +[GraphQL Federation](https://the-guild.dev/graphql/hive/federation) gateways. + + + For the setup of a new Nest project, please make sure to read the [Nest GraphQL + documentation](https://docs.nestjs.com/graphql/quick-start). + + +## Install + +```sh npm2yarn +npm i @nestjs/graphql @graphql-hive/nestjs graphql +``` + +## Create Application Module + +```typescript +import { HiveGatewayDriver, HiveGatewayDriverConfig } from '@graphql-hive/nestjs' +import { Module } from '@nestjs/common' +import { GraphQLModule } from '@nestjs/graphql' + +@Module({ + imports: [ + GraphQLModule.forRoot({ + driver: HiveGatewayDriver, + // All configuration for Hive Gateway comes here; + supergraph: './supergraph.graphql', + // Install subscription handlers to the server + installSubscriptionHandlers: true, + subscriptions: { + // Enable WebSocket subscriptions + 'graphql-ws': true + } + }) + ] +}) +export class AppModule {} +``` + + + Learn more about subscriptions in Hive Gateway [here](/docs/gateway/subscriptions). + + +## Further development + +Hive Gateway offers just a gateway driver; meaning, everything else works as +[showcased in Nest federation documentation](https://docs.nestjs.com/graphql/federation).