GraphQLConverterFactory
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
The factory owns every response type except ResponseBody itself, so it is intended for GraphQL-only endpoints.
Codec failures propagate as co.anitrend.retrofit.graphql.serialization.GraphQLRequestEncodingException or co.anitrend.retrofit.graphql.serialization.GraphQLResponseDecodingException; response conversion never prints failures or converts them to null.
The legacy GraphConverter path is isolated in
:compat;:runtimecarries no Gson or kotlinx.serialization dependency.
Parameters
The explicit GraphQLTransportCodec used for every request and response conversion performed by this factory.
Optional GraphQLDocumentRegistry, retained for API parity and the upcoming APQ phase. Never consulted while the neutral request carries its document.
See also
Functions
Returns the GraphQLRequestConverter used to encode request bodies through the factory's GraphQLTransportCodec.
Returns the GraphQLResponseConverter used to decode response bodies through the factory's GraphQLTransportCodec.