Scalar Types
You'll learn what GraphQL's built-in scalar types are and how they form the foundation of every GraphQL schema.
What Are Scalar Types?
In GraphQL, scalar types represent the leaves of your query—they're the primitive values that can't be broken down any further. Think of them like atoms in chemistry: the smallest, indivisible units that make up everything else.
When you define fields in your GraphQL schema, they must ultimately resolve to scalar values. These are the actual data points your API returns: strings, numbers, booleans, and identifiers.
The Five Built-In Scalars
GraphQL comes with five standard scalar types out of the box:
String: UTF-8 character sequences like"Hello"or"user@example.com"Int: Signed 32-bit integers like42or-10Float: Signed double-precision floating-point values like3.14or-0.5Boolean: True or false values:trueorfalseID: A unique identifier, serialized as a String but semantically represents a unique ID (often used for cache keys)
The ID type is special—while it looks like a String, it signals to both clients and servers that this field uniquely identifies an object.
Custom Scalars
Beyond the built-ins, GraphQL lets you define custom scalars for domain-specific types like Date, DateTime, Email, or URL. These allow you to enforce validation and formatting at the type level, making your API safer and more expressive.
Custom scalars require you to define how they serialize (send to clients), deserialize (receive from clients), and validate internally.
Key Takeaway: Scalar types are GraphQL's primitive values—the five built-in scalars (String, Int, Float, Boolean, ID) form the foundation of all data, and custom scalars let you extend the type system for specialized values.