Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs/Gateway: NestJS integration #6545

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
description:
Nest (Nest JS) is a progressive Node.js framework for building efficient, reliable and scalable
server-side applications.
Comment on lines +3 to +4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a description of Nest, not our Hive GW driver for Nest. I'd rephrase it to say something like: "Hive Gateway driver for Nest, a progressive Node.js [...]"

---

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 support building
[GraphQL Federation](https://the-guild.dev/graphql/hive/federation) gateways including
[subscription support](/docs/gateway/subscriptions) that do not exist in the default Nest Federation
drivers.
Comment on lines +14 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some grammar fixes and removed the last part of the sentence, there's no need to state that subscriptions dont exist in Nest's Federation driver.

Suggested change
Hive Gateway provides its own Nest GraphQL Driver that support building
[GraphQL Federation](https://the-guild.dev/graphql/hive/federation) gateways including
[subscription support](/docs/gateway/subscriptions) that do not exist in the default Nest Federation
drivers.
Hive Gateway provides its own Nest GraphQL Driver that supports building
[GraphQL Federation](https://the-guild.dev/graphql/hive/federation) gateways including
[subscriptions support](/docs/gateway/subscriptions).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it a good selling point for Hive Gateway driver compared to default options?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's enough to say that we support subscriptions, no need to connect ourselves to Nest. Also, this might change in the future and not saying anything about Nest keeps the docs up-to-date on its own.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Nest docs, it says gateway doesn't support subscriptions which might be misleading on our end like we also do not support. My point is to emphasize that we support unlike the default existing options for the Federation Gateway with Nest.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it'll be misleading since we explicitly say that we support subscriptions.

But we don't have to dwell into this, I have no hard opinion. You can put the last part back, just make sure to fix the grammar: "[…] that does not exist […]".


<Callout>
For the setup of a new Nest project, please make sure to read the [Nest GraphQL
documentation](https://docs.nestjs.com/graphql/quick-start).
</Callout>

## 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<HiveGatewayDriverConfig>({
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 {}
```

<Callout>
Learn more about subscriptions in Hive Gateway [here](/docs/gateway/subscriptions).
</Callout>

## 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).
Loading