GraphResponseConverter

open class GraphResponseConverter<T>(type: Type?, json: GraphQLJson) : Converter<ResponseBody, T> (source)

Deprecated

Legacy response converter of the GraphConverter flow. Use GraphQLResponseConverter with an explicit GraphQLTransportCodec instead.

GraphQL response body converter to unwrap nested object results, resulting in a smaller generic tree for requests.

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.response.GraphQLResponseConverter from :runtime.

Serialization

Response deserialization is delegated to GraphQLJson.decode. The full parameterized type (e.g. GraphContainer<GetCurrentUserData>) is forwarded so that serializers with parameterized type awareness (e.g. KotlinxGraphQLJson via kotlinx.serialization.serializer(type)) can resolve the correct KSerializer.

GraphQLJson.decode may throw if the response JSON is invalid or if no serializer can be resolved for the target type. These errors propagate to Retrofit's caller.

Parameters

type

The target deserialization type including parameterized type info (e.g. GraphContainer<Foo>). Must not be null when called from Retrofit.

json

Pluggable GraphQLJson instance for deserialization.

See also

Constructors

Link copied to clipboard
constructor(type: Type?, json: GraphQLJson)

Functions

Link copied to clipboard
open override fun convert(responseBody: ResponseBody): T?

Converter contains logic on how to handle responses, since GraphQL responses follow the JsonAPI spec it makes sense to wrap our base query response data and errors response in here, the logic remains open to the implementation