GraphQLJson
Deprecated
Legacy GraphQLJson serialization seam for GraphConverter. Use GraphQLTransportCodec with the backend-neutral GraphQLConverterFactory instead.
Pluggable serialization abstraction for GraphQL request and response bodies.
This is the legacy serialization seam of the deprecated GraphConverter path. It is retained in :compat for backward compatibility; new code should use co.anitrend.retrofit.graphql.serialization.GraphQLTransportCodec instead, which is backend-neutral and consumed by the new co.anitrend.retrofit.graphql.converter.GraphQLConverterFactory.
Implementations
| Implementation | Module | Notes |
|---|---|---|
| GsonGraphQLJson | :compat | Gson-backed. Handles all types including GraphContainer.extensions and GraphQLRequest.extensions. |
| KotlinxGraphQLJson | :compat | kotlinx.serialization-backed. Handles parameterized types via JVM reflection extension. GraphContainer.extensions and GraphQLRequest.extensions are @Transient. Recommended for response DTOs. |
Implementing a custom backend
class MoshiGraphQLJson(private val moshi: Moshi) : GraphQLJson {
override fun <T : Any> encode(value: T, type: Type?): String = ...
override fun <T : Any> decode(json: String, type: Type): T = ...
}Content copied to clipboard
Register with GraphConverter.create(context, json = MoshiGraphQLJson(...)).