Uuid — GraphQL Custom Scalar

Author – ChilliCream

Date – 2026-01-05

1Overview

The Uuid scalar type represents a Universally Unique Identifier (UUID) as defined by RFC 9562. It is intended for scenarios where globally unique identifiers are required, such as database primary keys, distributed system identifiers, or any situation requiring collision-resistant unique identifiers.

Unlike the built-in ID scalar which can be any string or number, Uuid enforces the specific format and structure of UUIDs, providing stronger guarantees about uniqueness and format validity.

The scalar uses the standard UUID string representation as defined in RFC 9562.

3Result spec

A Uuid scalar must serialize to a string conforming to the UUID string representation defined in RFC 9562. This represents a UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx where each x is a hexadecimal digit (0-9, a-f, A-F).

The format is:

Both lowercase and uppercase hexadecimal digits are valid.

3.1Examples

These are valid result values:

Value Explanation
"123e4567-e89b-12d3-a456-426614174000" A valid UUID (lowercase).
"123E4567-E89B-12D3-A456-426614174000" A valid UUID (uppercase).
"00000000-0000-0000-0000-000000000000" The nil UUID.
"550e8400-e29b-41d4-a716-446655440000" A valid UUID v4.

These are invalid result values:

Value Why is it invalid
"123e4567-e89b-12d3-a456-42661417400" Too few digits in last group.
"123e4567-e89b-12d3-a456-4266141740000" Too many digits in last group.
"123e4567e89b12d3a456426614174000" Missing hyphens.
"123e4567-e89b-12d3-a456" Incomplete UUID.
"g23e4567-e89b-12d3-a456-426614174000" Invalid character (g).
123 Not a string value.

4Input spec

A Uuid scalar accepts string values conforming to the UUID string representation defined in RFC 9562, both as GraphQL literals and as JSON input values.

The input format matches the result format and must:

Implementations should validate:

4.1Examples

Valid input values:

GraphQL Literal:

query {
  user(id: "123e4567-e89b-12d3-a456-426614174000") {
    name
  }
}

JSON input:

{
  "id": "123e4567-e89b-12d3-a456-426614174000"
}
{
  "userId": "550e8400-e29b-41d4-a716-446655440000"
}

Invalid input values:

Value Why is it invalid
"123e4567-e89b-12d3-a456-42661417400" Too few digits.
"123e4567e89b12d3a456426614174000" Missing hyphens.
"123e4567-e89b-12d3-a456" Incomplete UUID.
"g23e4567-e89b-12d3-a456-426614174000" Invalid character (g).
"" Empty string.

5References

  1. 1Overview
  2. 2Recommended name
  3. 3Result spec
    1. 3.1Examples
  4. 4Input spec
    1. 4.1Examples
  5. 5References