toState

@ApolloExperimental
fun <D : Operation.Data> ApolloCall<D>.toState(context: CoroutineContext = EmptyCoroutineContext): State<ApolloResponse<D>?>

Returns a State that produces ApolloResponses for this ApolloCall. Execution happens at first call. The initial value is null, which can be used to mean 'waiting for the first value'. ApolloResponse.exception can be used to check for ApolloExceptions thrown during execution. Example:

    val response by apolloClient.query(MyQuery()).toState()
when {
response == null -> Loading()
response!!.exception != null -> NetworkError(response!!.exception!!)
response!!.hasErrors() -> BackendError(response!!.errors!!)
else -> Screen(response!!.data!!)
}