What are GraphQL scalars?

Beginner

Answer

Scalars are primitive data types that represent leaf values in GraphQL. Built-in scalars include:

  • String: UTF-8 character sequence
  • Int: 32-bit signed integer
  • Float: Double-precision floating-point
  • Boolean: true or false
  • ID: Unique identifier

You can also define custom scalars:

scalar Date
scalar Email
scalar URL

type User {
  id: ID!
  email: Email!
  birthDate: Date
}