Short — GraphQL Custom Scalar

Author – ChilliCream

Date – 2025-12-29

1Overview

The Short scalar type represents a signed 16-bit integer. It is intended for scenarios where values are constrained to the range -32,768 to 32,767, providing a more compact representation than the built-in Int scalar for smaller integer values.

Unlike the built-in Int scalar which represents signed 32-bit integers, Short provides stronger type safety and validation for values that must fit within a signed 16-bit range.

3Result spec

A Short scalar must serialize to an integer value in the range -32,768 to 32,767 (inclusive).

3.1Examples

These are valid result values:

Value Explanation
0 Zero.
-32768 Minimum short value.
32767 Maximum short value.

These are invalid result values:

Value Why is it invalid
-32769 Below minimum short value (-32,768).
32768 Exceeds maximum short value (32,767).
3.14 Fractional values are not allowed.
"1000" Must be a number, not a string.

4Input spec

A Short scalar accepts integer values in the range -32,768 to 32,767 (inclusive), both as GraphQL literals and as JSON input values.

Implementations should validate:

4.1Examples

Valid input values:

GraphQL Literal:

mutation {
  setTemperature(celsius: -40) {
    id
  }
}

JSON input:

{
  "celsius": -40
}
{
  "count": 32767
}

Invalid input values:

Value Why is it invalid
-32769 Below minimum short value (-32,768).
32768 Exceeds maximum short value (32,767).
3.14 Fractional values are not allowed.
"1000" Must be a number, not a string.

5References

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