Recall & Review
beginner
What is an Object Type in NestJS GraphQL?
An Object Type defines the shape of data that the GraphQL API returns. It is a class decorated with @ObjectType() that describes fields and their types for the API response.Click to reveal answer
beginner
What is an Input Type in NestJS GraphQL and how is it used?
An Input Type is a class decorated with @InputType() used to define the shape of data sent by clients to the API, such as arguments for mutations or queries.Click to reveal answer
beginner
How do you define a simple Object Type with two fields: id (number) and name (string)?
Use a class with @ObjectType() and decorate fields with @Field(). Example:
@ObjectType()
class User {
@Field()
id: number;
@Field()
name: string;
}Click to reveal answer
intermediate
Why should Input Types be separate from Object Types in NestJS GraphQL?
Separating Input Types from Object Types helps keep input validation clear and prevents exposing internal fields in API responses. It also avoids circular references.
Click to reveal answer
intermediate
How do you reuse fields between Object Types and Input Types in NestJS?
You can create a base class with shared fields and extend it in both @ObjectType() and @InputType() classes to avoid repeating code.Click to reveal answer
Which decorator is used to define an Object Type in NestJS GraphQL?
✗ Incorrect
The @ObjectType() decorator marks a class as a GraphQL Object Type for API responses.
What decorator marks a class as an Input Type in NestJS GraphQL?
✗ Incorrect
The @InputType() decorator defines a class used for input data in GraphQL queries or mutations.
Why should Input Types and Object Types be separate in NestJS GraphQL?
✗ Incorrect
Separating them helps keep input validation clear and prevents exposing internal data or circular dependencies.
Which decorator is used to define fields inside Object or Input Types?
✗ Incorrect
@Field() marks a property as a GraphQL field in Object or Input Types.
How can you reuse fields between Object Types and Input Types in NestJS?
✗ Incorrect
Inheritance with a shared base class allows reusing fields in both Object and Input Types.
Explain the difference between Object Types and Input Types in NestJS GraphQL and why both are important.
Think about what data the server sends versus what it receives.
You got /4 concepts.
Describe how to create a reusable set of fields for both Object Types and Input Types in NestJS.
Consider how inheritance works in classes.
You got /4 concepts.