KotlinxGraphQLTransportCodec

class KotlinxGraphQLTransportCodec(json: Json = Json { ignoreUnknownKeys = true }) : GraphQLTransportCodec(source)

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:

Exception policy

Every failure is wrapped in GraphQLRequestEncodingException or GraphQLResponseDecodingException with the operation or response type context; backend exceptions never leak.

Parameters

json

A configured Json instance. Defaults to Json with Json.ignoreUnknownKeys enabled so fields not present in the generated data classes are silently skipped.

See also

Constructors

Link copied to clipboard
constructor(json: Json = Json { ignoreUnknownKeys = true })

Functions

Link copied to clipboard
open override fun <T : Any> decodeResponse(body: String, responseType: Type): T
Link copied to clipboard
open override fun encodeRequest(request: GraphQLOperationRequest<*>, requestType: Type): String