Any — GraphQL Custom Scalar
Author – ChilliCream
Date – 2026-01-06
License and Copyright
Copyright © GraphQL contributors. This specification is licensed under OWFa 1.0.
1Overview
The Any scalar type represents any valid GraphQL value. It is intended for scenarios where the type of data is dynamic or not known at schema definition time, such as configuration objects, metadata, flexible schemas, or polymorphic data structures.
Unlike typed GraphQL objects which have a fixed schema, Any allows for any valid GraphQL value including objects, lists, strings, numbers, booleans, and null. This provides flexibility at the cost of losing GraphQL’s type safety for that field.
Note: Object field names must be valid GraphQL names (matching the pattern /[_A-Za-z][_0-9A-Za-z]*/).
2Recommended name
The recommended name for this scalar is Any.
3Result spec
An Any scalar serializes as any valid GraphQL value. This can be:
- A GraphQL object (represented as a map of field names to values)
- A GraphQL list (represented as an array of values)
- A GraphQL string
- A GraphQL integer or float
- A GraphQL boolean
- A GraphQL null value
The serialized format depends on the transport mechanism used (typically JSON over HTTP, but GraphQL is transport-agnostic).
3.1Examples
These are valid result values:
| Value | Explanation |
|---|---|
{ "name": "John", "age": 30 } |
An object value. |
[1, 2, 3, 4, 5] |
A list value. |
"Hello, World!" |
A string value. |
42 |
An integer value. |
3.14159 |
A float value. |
true |
A boolean value. |
null |
A null value. |
{ "nested": { "data": [1, 2, 3] } } |
Nested structure. |
These are invalid result values:
| Value | Why is it invalid |
|---|---|
{ "123invalid": "value" } |
Field name doesn’t match name pattern. |
ACTIVE |
Enum values are not valid. |
4Input spec
An Any scalar accepts any valid GraphQL value, both as GraphQL literals and as input values.
The input can be:
- A GraphQL input object
- A GraphQL list
- A GraphQL string
- A GraphQL integer or float
- A GraphQL boolean
- A GraphQL null value
4.1Examples
Valid input values:
GraphQL Literal:
mutation {
updateMetadata(data: { theme: "dark", notifications: true }) {
id
}
}
JSON input:
{
"data": {
"theme": "dark",
"notifications": true
}
}
{
"tags": ["important", "urgent", "review"]
}
{
"count": 42
}
Invalid input values:
| Value | Why is it invalid |
|---|---|
{ "123invalid": "value" } |
Field name doesn’t match name pattern. |
ACTIVE |
Enum values are not valid. |
5References
- GraphQL Specification – Input Values — GraphQL input value specification