Mutations — GraphQL · NestJS

Change the cats through the schema: input types that describe what a client may send, validated by class-validator, a partial update derived from the create input, and Nest's exceptions as GraphQL errors.

What you will learn

Read the theory for Mutations

All GraphQL lessons

All NestJS courses

loading types…

What you'll learn

  • Declare what a client may send with @InputType() classes, and take them as a mutation's argument
  • Write @Mutation() resolvers that change state and return what changed
  • Validate input types with the global ValidationPipe and class-validator, and read a refusal as a GraphQL error
  • Derive an update input with PartialType from @nestjs/graphql, which keeps the fields' GraphQL types and their validation