What is NestJS GraphQL module?
Answer
NestJS has first-class GraphQL support via @nestjs/graphql which wraps Apollo Server or Mercurius. Two approaches: Code-first: define the schema using TypeScript classes with decorators (@ObjectType(), @Field(), @Resolver(), @Query(), @Mutation()) — the schema is auto-generated. Schema-first: write a .graphql SDL file and NestJS generates TypeScript interfaces from it. The code-first approach is preferred for TypeScript projects as it avoids schema/type duplication. DataLoader integration handles N+1 query problems. Subscriptions are supported over WebSocket. Guards, Interceptors, and Pipes work in GraphQL context when using ExecutionContext.switchToHttp()-aware alternatives.
Previous
How do you handle database transactions in NestJS with TypeORM?
Next
How do you implement WebSocket support in NestJS?
More NestJS Questions
View all →- Intermediate How does NestJS dependency injection scoping work?
- Intermediate What are NestJS microservices and what transports are supported?
- Intermediate What is the ExecutionContext in NestJS?
- Intermediate How do you implement role-based access control (RBAC) in NestJS?
- Intermediate What is the Reflector in NestJS and how is it used?