Archives: FAQs

Q: How does the subscription get triggered in the example?

 A: In the example, a createUser mutation is implemented. Whenever this mutation is called, the code publishes a “newUser” event via the PubSub, so any client subscribed to that event receives the new user data in real time.

Q: What setup is needed to enable GraphQL subscriptions in a NestJS app?

A: You need to install the GraphQL + subscription libraries (@nestjs/graphql, @nestjs/apollo, plus subscriptions-transport-ws or graphql-ws), configure your GraphQL module to enable WebSocket transport, define resolvers for subscription events in addition to queries/mutations, and use a PubSub mechanism to publish events.

Q: Why choose NestJS for real-time GraphQL subscriptions?

A: NestJS provides a modular architecture out of the box, TypeScript support, dependency injection, and built-in support for GraphQL via packages like @nestjs/graphql. It’s well-suited for scalable server applications needing structured code.

Q: What’s the folder or component structure in the example app?

A: There’s a React app with components like a form to create new users, a list component showing users, and a table UI. The app uses a React Router for navigating between list view and form view. Subscription logic is placed in a component listening for new user registration events.

Q: What are the security considerations in this deployment?

 A: Some include: using SSH via keys rather than weak password auth, ensuring only necessary ports are open, handling secrets (e.g. in GitHub Actions), and likely using least privilege access. The blog mentions they used password auth but plan to look at SSH key auth for better security.

Back To Top