GraphRequestConverter

open class GraphRequestConverter(methodAnnotations: Array<out Annotation>, graphProcessor: AbstractGraphProcessor, json: GraphQLJson, registry: GraphQLDocumentRegistry? = null, type: Type? = null) : Converter<Any, RequestBody> (source)

Deprecated

Legacy request converter of the GraphConverter flow. Use GraphQLRequestConverter with an explicit GraphQLTransportCodec instead.

GraphQL request body converter and injector, uses method annotation for a given retrofit method.

Legacy: this converter lives in :compat for the deprecated co.anitrend.retrofit.graphql.converter.GraphConverter flow. New code should use the backend-neutral co.anitrend.retrofit.graphql.converter.request.GraphQLRequestConverter from :runtime.

Supports both the typed GraphQLRequest flow (legacy; codegen consumers should use the backend-neutral co.anitrend.retrofit.graphql.model.request.GraphQLOperationRequest with GraphQLRequestConverter instead) and the legacy QueryContainerBuilder flow (Gson-only).

Serialization

Request serialization is delegated to GraphQLJson.encode:

  • GraphQLRequest: The request object is serialized directly. When type is available (provided by Retrofit), it is forwarded to GraphQLJson.encode so that serializers with parameterized type awareness (e.g. kotlinx.serialization) can resolve the correct KSerializer<GraphQLRequest<FooVariables>>.

  • QueryContainerBuilder: The built QueryContainer is serialized through Gson for backward compatibility. QueryContainer is not @Serializable, so the legacy builder flow always uses a Gson-backed encoder even when the response/request backend is kotlinx.serialization.

Document Resolution

When a GraphQLDocumentRegistry is provided, it is checked before falling back to the asset-based AbstractGraphProcessor lookup (only for QueryContainerBuilder flow). Registry-only converter factory overloads use a strict no-op processor that throws when an annotated operation is missing.

Parameters

methodAnnotations

Annotations applied to the Retrofit method.

graphProcessor

The processor used for asset-based query resolution.

json

Pluggable GraphQLJson instance for request body serialization.

registry

Optional registry providing build-time generated documents and hashes.

type

The type of the request body parameter, including parameterized type info (e.g. GraphQLRequest). May be null when constructed outside Retrofit.

See also

Constructors

Link copied to clipboard
constructor(methodAnnotations: Array<out Annotation>, graphProcessor: AbstractGraphProcessor, json: GraphQLJson, registry: GraphQLDocumentRegistry? = null, type: Type? = null)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun convert(value: Any): RequestBody

Converter for the request body. Dispatches to the appropriate handler based on the body type.