0
0
NestJSframework~5 mins

Resolvers in NestJS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a Resolver in NestJS GraphQL?
A Resolver is a special class in NestJS that handles GraphQL queries and mutations. It connects GraphQL requests to the code that fetches or modifies data.
Click to reveal answer
beginner
How do you define a Query in a NestJS Resolver?
You use the @Query() decorator on a method inside a Resolver class. This method runs when the GraphQL query with the same name is called.
Click to reveal answer
beginner
What decorator is used to create a Mutation in a NestJS Resolver?
The @Mutation() decorator is used on a method inside a Resolver class to handle GraphQL mutations, which change data.
Click to reveal answer
intermediate
Why do Resolvers use dependency injection in NestJS?
Resolvers use dependency injection to get services that handle the actual data logic. This keeps the Resolver focused on GraphQL and clean code separation.
Click to reveal answer
beginner
What is the role of the @Resolver() decorator in NestJS?
The @Resolver() decorator marks a class as a GraphQL Resolver. It can optionally take an object type to link the Resolver to a GraphQL type.
Click to reveal answer
Which decorator defines a GraphQL query method in a NestJS Resolver?
A@Injectable()
B@Mutation()
C@Resolver()
D@Query()
What does the @Resolver() decorator do?
ADefines a GraphQL mutation
BMarks a class as a GraphQL Resolver
CInjects a service into a class
DCreates a GraphQL schema
How do Resolvers get access to services in NestJS?
AUsing dependency injection in the constructor
BBy importing them directly
CUsing global variables
DBy calling static methods
Which decorator is used to handle data changes in GraphQL with NestJS?
A@Mutation()
B@Resolver()
C@Query()
D@Controller()
What is the main purpose of a Resolver in NestJS GraphQL?
ATo define REST endpoints
BTo manage database connections
CTo connect GraphQL requests to data logic
DTo style the frontend
Explain how to create a simple Query Resolver method in NestJS and what it does.
Think about how a method is marked to respond to a GraphQL query.
You got /4 concepts.
    Describe the role of dependency injection in NestJS Resolvers and why it is useful.
    Consider how services are provided to Resolvers without manual creation.
    You got /4 concepts.