-
Notifications
You must be signed in to change notification settings - Fork 110
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. | ||||||||||||||||
--- | ||||||||||||||||
|
||||||||||||||||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 NestJS federation documentation](https://docs.nestjs.com/graphql/federation). | ||||||||||||||||
ardatan marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
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 [...]"