GraphQLConverterFactory

class GraphQLConverterFactory(codec: GraphQLTransportCodec, registry: GraphQLDocumentRegistry? = null) : Converter.Factory(source)

Backend-neutral Converter.Factory for Retrofit GraphQL endpoints.

GraphQLConverterFactory is the neutral counterpart of the legacy GraphConverter. It is the only factory in :runtime whose request and response conversion is fully delegated to a GraphQLTransportCodec; it never references a JSON backend, an Android android.content.Context, or asset discovery.

Explicit codec ownership

Every creation path requires an explicit GraphQLTransportCodec. There is no default codec, no reflection-based codec selection, no backend instantiation, and no retry/fallback: the codec instance passed to create (or to the constructor) is the only serialization path used.

val factory = GraphQLConverterFactory.create(
codec = GsonGraphQLTransportCodec(),
)
Retrofit.Builder()
.baseUrl("https://api.github.com/graphql")
.addConverterFactory(factory)
.build()

Request contract

Request conversion accepts only GraphQLOperationRequest bodies. Any other body type fails during conversion with an IllegalArgumentException that names both the actual type and the expected neutral type.

Registry semantics

create optionally accepts a GraphQLDocumentRegistry for API parity with legacy factories and for the upcoming persisted query (APQ) phase. Because GraphQLOperationRequest always carries its document, request conversion never consults the registry: no hidden lookup is performed while the neutral request already contains its query.

Capability boundaries

Parameters

codec

The explicit GraphQLTransportCodec used for every request and response conversion performed by this factory.

registry

Optional GraphQLDocumentRegistry, retained for API parity and the upcoming APQ phase. Never consulted while the neutral request carries its document.

See also

Constructors

Link copied to clipboard
constructor(codec: GraphQLTransportCodec, registry: GraphQLDocumentRegistry? = null)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun requestBodyConverter(type: Type, parameterAnnotations: Array<out Annotation>, methodAnnotations: Array<out Annotation>, retrofit: Retrofit): Converter<*, RequestBody>?

Returns the GraphQLRequestConverter used to encode request bodies through the factory's GraphQLTransportCodec.

Link copied to clipboard
open override fun responseBodyConverter(type: Type, annotations: Array<out Annotation>, retrofit: Retrofit): Converter<ResponseBody, *>?

Returns the GraphQLResponseConverter used to decode response bodies through the factory's GraphQLTransportCodec.

Link copied to clipboard
open fun stringConverter(type: Type?, annotations: Array<out Annotation?>?, retrofit: Retrofit?): Converter<*, String?>?