ApolloResponse

Represents a GraphQL response or an exception if no GraphQL response is received.

  • data contains the parsed data returned in the response

  • errors contains any GraphQL errors returned in the response

  • exception contains an exception if a GraphQL response wasn't received

GraphQL responses can contain partial data, so it is possible to have both data != null and errors != null. An ApolloResponse may be in any of these states:

  • exception == null && data != null && errors == null: complete data with no errors

  • exception == null && data != null && errors != null: partial data with GraphQL errors

  • exception == null && data == null && errors != null: no data, only GraphQL errors

  • exception == null && data == null && errors == null: no data and no errors - while technically possible, this should not happen with a spec-compliant server

  • exception != null && data == null && errors == null: no GraphQL response was received due to a network error or otherwise

Types

Link copied to clipboard

Properties

Link copied to clipboard

Parsed response of GraphQL operation execution. data is non-null if some data is received from the server. data might contain partial data in case of field errors

Link copied to clipboard
@get:JvmName(name = "dataAssertNoErrors")
val dataAssertNoErrors: D

A shorthand property to get a non-nullable data if handling partial data is not important

Link copied to clipboard

GraphQL errors returned by the server to let the client know that something has gone wrong.

Link copied to clipboard

An ApolloException if a GraphQL response wasn't received.

Link copied to clipboard

The context of GraphQL operation execution. This can contain additional data contributed by interceptors.

Link copied to clipboard

Extensions of GraphQL protocol, arbitrary map of key String / value Any sent by server along with the response.

Link copied to clipboard

Indicates that this ApolloResponse is the last ApolloResponse in a given Flow and that no other items are expected.

Link copied to clipboard

The GraphQL operation this response represents

Link copied to clipboard

Functions

Link copied to clipboard
fun dataOrThrow(): D

Return data if not null or throws NoDataException else

Link copied to clipboard
Link copied to clipboard