GsonGraphQLTransportCodec
Gson-backed implementation of GraphQLTransportCodec.
GsonGraphQLTransportCodec serializes GraphQLOperationRequest envelopes and deserializes GraphQLResponse envelopes with Gson only inside this module. It is the neutral counterpart of the legacy co.anitrend.retrofit.graphql.serialization.gson.GsonGraphQLJson (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) using the complete parameterized request Type, so typed variables are resolved from the declared generic arguments rather than the runtime class. With the default Gson instance, 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 Gson instance. Defaults to a Gson with null serialization enabled so absent request fields stay explicit.