LocalDate — GraphQL Custom Scalar

Author – ChilliCream

Date – 2025-12-24

1Overview

The LocalDate scalar type represents a date without time or time zone information. It is intended for scenarios where only the calendar date matters in a local context, such as contract effective dates, publication dates, or recurring events (e.g., “New Year’s Day is January 1st”), where the specific time of day and time zone are irrelevant or managed separately.

Unlike instant-based DateTime scalars that represent a specific moment in time, LocalDate represents a calendar date that could refer to different moments depending on the time zone context applied to it. This makes it suitable for applications where only the date component is meaningful.

The scalar uses RFC 3339 format for serialization, specifically the full-date production.

3Result spec

A LocalDate scalar must serialize to a string conforming to the RFC 3339 full-date production. This represents a calendar date in the format: YYYY-MM-DD.

The format is:

3.1Examples

These are valid result values:

Value Explanation
"2023-12-24" December 24th, 2023.
"2000-02-29" February 29th, 2000 (leap year).

These are invalid result values:

Value Why is it invalid
"2023-12-24T15:30:00" Contains time component.
"2023-12-24T15:30:00Z" Contains time and time zone information.
"2023-13-01" Invalid month (13).
"2023-12-32" Invalid day (32).
"2023-2-5" Month and day must be zero-padded to two digits.
"23-12-24" Year must be four digits.
"2023/12/24" Invalid separator (slash instead of hyphen).
"2001-02-29" Invalid date (2001 is not a leap year).

4Input spec

A LocalDate scalar accepts string values conforming to the RFC 3339 full-date production, 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:

mutation {
  createContract(effectiveDate: "2000-12-24") {
    id
  }
}

JSON input:

{
  "effectiveDate": "2000-12-24"
}

Invalid input values:

Value Why is it invalid
"2023-12-24T15:30:00" Contains time component.
"2023-13-01" Invalid month (13).
"2023-12-32" Invalid day (32).
"2023-2-5" Month and day must be zero-padded.
"2023/12/24" Invalid separator.
"2023-02-30" Invalid date (February 30th).

5References

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