Decorate resolver methods with @Mutation(() => ReturnType). Always use @InputType() classes for mutation arguments — never @ObjectType(). Suffix input types with Input (e.g. CreateUserInput). Return the mutated object when possible so clients can update their Apollo cache without a follow-up query.
- 1
Suffix all input types with Input — CreateUserInput, UpdateUserInput, DeleteUserInput.
- 2
Use @InputType() for mutation arguments — never @ObjectType().
- 3
Return the mutated object when possible — clients can update their Apollo cache without re-fetching.
- 4
Use PartialType(CreateUserInput) for update inputs — all fields become optional with same validations.
- 5
Boolean return type is acceptable for delete mutations when the entity is no longer accessible.
Scenario Questions
0-2 years experience
- 1Can you walk me through how you'd create a simple `createUser` mutation in a NestJS resolver, including the DTO you’d use for the input?
- 2If you forget to add the `@Args('input')` decorator on the mutation method parameter, what error would you see at runtime?
- 3What naming convention would you follow for the input type class, and why does it matter for the generated GraphQL schema?