YearMonth — GraphQL Custom Scalar
Author – apollographql
Date - 2025-12-04
License and Copyright
Copyright © GraphQL contributors. This specification is licensed under OWFa 1.0.
1Overview
This scalar represents a year and month, without any reference to a time zone.
Using RFC 3339 format, a YearMonth is represented as date-fullyear "-" date-month:
date-fullyear = 4DIGIT ; 0000-9999
date-month = 2DIGIT ; 01-12
2Recommended Name
The recommended name is YearMonth.
3GraphQL input coercion
The input must be a GraphQL StringValue matching the description above.
All other values must raise an error.
4JSON input coercion
The input must be a JSON string matching the description above.
All other values must raise an error.
5JSON result coercion
The result must be a JSON string matching the description above.
6Examples
Because GraphQL StringValue and JSON string are so similar, the first column in the table below may be understood as either a GraphQL StringValue or a JSON string.
| Value | Description |
|---|---|
1983-10 |
A valid year and month. |
These are invalid examples:
| Value | Why is it invalid |
|---|---|
1983-01-20 |
Day is not allowed. |
1983-00 |
00 is not a valid month. |
10000-10 |
More than 4 digits for date-fullyear. |
52-10 |
Less than 4 digits for date-fullyear. |