GraphError

@Serializable
data class GraphError(val message: String? = null, val path: List<Any>? = null, val locations: List<GraphError.Location>? = null, val extensions: Map<String, Any?>? = null)(source)

Deprecated

Legacy serializer-coupled GraphQL error. Use GraphQLResponseError from the backend-neutral GraphQLResponse contract instead.

GraphQL error representation that is spec compliant.

Legacy: this serializer-coupled error type lives in :compat for the deprecated GraphContainer/co.anitrend.retrofit.graphql.converter.GraphConverter flow. New code should use the backend-neutral co.anitrend.retrofit.graphql.model.GraphQLResponseError instead.

Annotated with kotlinx.serialization.Serializable to enable deserialization as part of GraphContainer.errors when using kotlinx.

Serialization Behavior

kotlinx.serialization

  • message and locations are deserialized normally

  • path is @Transient (excluded) because List<Any> cannot be statically resolved by the kotlinx compiler plugin

  • extensions is @Transient (excluded) because Map<String, Any?> cannot be statically resolved by the kotlinx compiler plugin

Gson (via GsonGraphQLJson)

  • All fields are serialized/deserialized normally, including path and extensions

Accessing path and extensions with kotlinx

To read path or extensions while using kotlinx serialization, define your own @Serializable transport error class with concrete JSON element types. No custom serializer is required unless the actual wire structure needs transformation:

@Serializable
data class JsonGraphError(
val message: String? = null,
val path: List<JsonElement>? = null,
val locations: List<GraphError.Location>? = null,
val extensions: JsonObject? = null,
)

Alternatively, extract path and extensions from the raw JsonObject payload before kotlinx deserialization runs.

Parameters

message

Description of the error.

path

Path of the response field that encountered the error. Gson-only; @Transient for kotlinx.

locations

List of locations within the GraphQL document at which the error occurred.

extensions

Additional information about the error. Gson-only; @Transient for kotlinx.

See also

Constructors

Link copied to clipboard
constructor(message: String? = null, path: List<Any>? = null, locations: List<GraphError.Location>? = null, extensions: Map<String, Any?>? = null)

Types

Link copied to clipboard
@Serializable
data class Location(val line: Int = 0, val column: Int = 0)

Location describing which part of GraphQL document caused an exception.

Properties

Link copied to clipboard
@Transient
val extensions: Map<String, Any?>?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@Transient
val path: List<Any>?

Functions

Link copied to clipboard
open override fun toString(): String