UnsignedLong — GraphQL Custom Scalar

Author – ChilliCream

Date – 2026-01-09

1Overview

The UnsignedLong scalar type represents an unsigned 64-bit integer. It is intended for scenarios where values exceed the range of unsigned 32-bit integers, such as representing very large counts, file sizes, memory addresses, or any non-negative integer values requiring more than 32 bits.

Unlike the Long scalar which represents signed 64-bit integers with a range of -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807, UnsignedLong supports non-negative values in the range 0 to 18,446,744,073,709,551,615.

Note: JavaScript’s JSON.parse() does not safely support 64-bit integers. Values outside the safe integer range (0 to 2^53 - 1) may lose precision when parsed as JavaScript numbers. Client applications using JavaScript should handle UnsignedLong values with care, potentially using libraries like json-bigint or representing them as strings.

3Result spec

An UnsignedLong scalar must serialize to an integer value in the range 0 to 18,446,744,073,709,551,615 (inclusive).

3.1Examples

These are valid result values:

Value Explanation
0 Minimum unsigned long value.
18446744073709551615 Maximum unsigned long value.
9223372036854775808 A value exceeding signed long maximum.

These are invalid result values:

Value Why is it invalid
-1 Negative values are not allowed.
18446744073709551616 Exceeds maximum unsigned long value.
3.14 Fractional values are not allowed.
"1000" Must be a number, not a string.

4Input spec

An UnsignedLong scalar accepts integer values in the range 0 to 18,446,744,073,709,551,615 (inclusive), both as GraphQL literals and as JSON input values.

Implementations should validate:

4.1Examples

Valid input values:

GraphQL Literal:

query {
  fileInfo(sizeInBytes: 10000000000000000000) {
    name
  }
}

JSON input:

{
  "sizeInBytes": 10000000000000000000
}
{
  "maxValue": 18446744073709551615
}

Invalid input values:

Value Why is it invalid
-1 Negative values are not allowed.
18446744073709551616 Exceeds maximum unsigned long value.
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