Recall & Review
beginner
What is the Code-first approach in NestJS GraphQL?
It means you write your TypeScript classes and decorators first, then NestJS generates the GraphQL schema from your code automatically.
Click to reveal answer
beginner
How do you define a GraphQL object type using the Code-first approach in NestJS?
You create a TypeScript class and decorate it with @ObjectType(), then decorate its fields with @Field() to expose them in the GraphQL schema.Click to reveal answer
beginner
Why is the Code-first approach helpful for beginners?
Because you work directly with familiar TypeScript code and decorators, avoiding manual schema writing and reducing errors.
Click to reveal answer
beginner
Which decorator is used to mark a method as a GraphQL query in the Code-first approach?
The @Query() decorator is used on a method inside a resolver class to define a GraphQL query.Click to reveal answer
intermediate
How does NestJS generate the GraphQL schema in the Code-first approach?
NestJS scans your decorated classes and methods, then builds the schema automatically at runtime based on your code structure.
Click to reveal answer
In NestJS Code-first approach, which decorator marks a class as a GraphQL object type?
✗ Incorrect
The @ObjectType() decorator marks a class as a GraphQL object type in the Code-first approach.
Which decorator is used to expose a class property as a GraphQL field?
✗ Incorrect
The @Field() decorator exposes a class property as a GraphQL field.
What does the Code-first approach generate automatically from your code?
✗ Incorrect
The Code-first approach automatically generates the GraphQL schema from your decorated TypeScript code.
Which decorator defines a GraphQL query method in a resolver?
✗ Incorrect
The @Query() decorator marks a method as a GraphQL query.
Why might developers prefer Code-first over Schema-first in NestJS?
✗ Incorrect
Code-first uses decorators and TypeScript classes, which many find easier to maintain and less error-prone.
Explain how the Code-first approach works in NestJS for building a GraphQL API.
Think about how your code becomes the schema.
You got /5 concepts.
List the main decorators used in the Code-first approach and their purpose.
Focus on decorators that define schema and operations.
You got /5 concepts.