GraphQLValue
Backend-neutral representation of an arbitrary GraphQL JSON value.
GraphQLValue models the six JSON value shapes that can appear anywhere in a GraphQL payload (request extensions, response extensions, error extensions, error paths, and arbitrary vendor fields). It deliberately carries no serializer, platform, or HTTP framework types so that any JSON backend (Gson, kotlinx.serialization, Moshi, and so on) can map its own element model onto this hierarchy.
The hierarchy is exhaustive:
Null for explicit JSON
nullBooleanValue for JSON booleans
StringValue for JSON strings
NumberValue for JSON numbers
ListValue for JSON arrays
ObjectValue for JSON objects with String keys
Numeric precision
Numbers are held as BigDecimal so that arbitrary-precision JSON numbers survive a round trip without floating point loss. Note that BigDecimal.equals is scale-sensitive (1.0 and 1.00 are not equal); use compareTo when only the numeric value matters.
Usage
val extension = GraphQLValue.ObjectValue(
fields = mapOf(
"persistedQuery" to GraphQLValue.ObjectValue(
fields = mapOf(
"version" to GraphQLValue.NumberValue(BigDecimal(1)),
"sha256Hash" to GraphQLValue.StringValue("abc123"),
),
),
),
)See also
Inheritors
Types
JSON boolean value.
JSON array value.
Explicit JSON null.
JSON number value with full decimal precision.
JSON object value with String keys.
JSON string value.