Enums and scalars — GraphQL · NestJS

Give values their real types: a registered enum the schema lists and checks, dates that travel as ISO strings and arrive as Date objects, and a custom Microchip scalar that validates what clients send and formats what they get.

What you will learn

Read the theory for Enums and scalars

All GraphQL lessons

All NestJS courses

loading types…

What you'll learn

  • Register a TypeScript enum with registerEnumType(), with descriptions, and use it for fields and arguments
  • Use Date fields and arguments, which GraphQL carries as the DateTime scalar in ISO 8601
  • Write a custom scalar with GraphQLScalarType: serialize for answers, parseValue for variables, parseLiteral for inline values
  • Tell where each kind of value is checked: enums and scalars by GraphQL before any resolver runs