GraphQLResponse

data class GraphQLResponse<T>(val data: GraphQLData<T> = GraphQLData.Absent, val errors: List<GraphQLResponseError> = emptyList(), val extensions: GraphQLValue.ObjectValue? = null)(source)

Backend-neutral, spec-compliant GraphQL response envelope.

GraphQLResponse is the transport contract for a single GraphQL response before any Retrofit or HTTP concerns are applied. It is the neutral counterpart of the legacy, serializer-coupled co.anitrend.retrofit.graphql.model.body.GraphContainer.

The response data entry is modeled with GraphQLData so that callers can distinguish a missing data key (GraphQLData.Absent) from an explicit data: null (GraphQLData.Present with a null value).

Usage

val response = GraphQLResponse<Viewer>(
data = GraphQLData.Present(viewer),
extensions = GraphQLValue.ObjectValue(
fields = mapOf(
"cost" to GraphQLValue.ObjectValue(
fields = mapOf("requested" to GraphQLValue.NumberValue(BigDecimal(3))),
),
),
),
)

Type Parameters

T

The decoded type of the data entry.

See also

Constructors

Link copied to clipboard
constructor(data: GraphQLData<T> = GraphQLData.Absent, errors: List<GraphQLResponseError> = emptyList(), extensions: GraphQLValue.ObjectValue? = null)

Properties

Link copied to clipboard

The data entry, or GraphQLData.Absent when the response omits it.

Link copied to clipboard

The GraphQL errors, or an empty list when the response is successful.

Link copied to clipboard

Top-level response extensions (for example rate limit or cost metadata), or null when absent.