KotlinxGraphQLTransportCodec
kotlinx.serialization-backed implementation of GraphQLTransportCodec.
KotlinxGraphQLTransportCodec serializes GraphQLOperationRequest envelopes and deserializes GraphQLResponse envelopes with kotlinx serialization only inside this module. It is the neutral counterpart of the legacy co.anitrend.retrofit.graphql.serialization.kotlinx.KotlinxGraphQLJson (which moved to :compat with the deprecated GraphConverter flow) and never routes through the generic co.anitrend.retrofit.graphql.model.GraphQLJson seam.
Request encoding
encodeRequest writes the neutral envelope (query, operationName, variables, extensions). Typed variables are encoded through the serializer resolved from the first generic argument of the complete parameterized request Type, falling back to the runtime class of the variables when the type is not parameterized. Absent variables and extensions are written as explicit JSON nulls.
Response decoding
decodeResponse preserves the neutral protocol semantics:
A missing
datakey decodes to GraphQLData.Absent, while an explicitdata: nulldecodes to GraphQLData.Present with a null value.Error
messageis required: missing, null, or non-string messages fail with GraphQLResponseDecodingException.Error
pathsegments decode to GraphQLPathSegment.Field for strings and GraphQLPathSegment.Index for integral numbers; non-integral or non-scalar segments fail.Top-level and error
extensionsdecode to GraphQLValue.ObjectValue with exact java.math.BigDecimal precision for numbers.Explicit JSON nulls for optional
errors/extensionsfields are treated as absent.
Exception policy
Every failure is wrapped in GraphQLRequestEncodingException or GraphQLResponseDecodingException with the operation or response type context; backend exceptions never leak.
Parameters
A configured Json instance. Defaults to Json with Json.ignoreUnknownKeys enabled so fields not present in the generated data classes are silently skipped.