public interface ApolloPrefetch extends Cancelable
ApolloPrefetch is an abstraction for a request that has been prepared for execution. It represents a single request/response pair and cannot be executed twice, though it can be cancelled. It fetches the graph response from the server on successful completion but doesn't inflate the response into models. Instead it stores the raw response in the request/response cache and defers the parsing to a later time.
Use this object for use cases when the data needs to be fetched, but is not required for immediate consumption. e.g.background update/syncing.
Note: In order to execute the request again, call the clone() method which creates a new
ApolloPrefetch object.
| Modifier and Type | Interface and Description |
|---|---|
static class |
ApolloPrefetch.Callback
Communicates responses from the server.
|
static interface |
ApolloPrefetch.Factory
Factory for creating ApolloPrefetch object.
|
| Modifier and Type | Method and Description |
|---|---|
ApolloPrefetch |
clone()
Creates a new, identical ApolloPrefetch to this one which can be enqueued or executed even if this one has already
been executed.
|
ApolloPrefetch |
enqueue(ApolloPrefetch.Callback callback)
Schedules the request to be executed at some point in the future.
|
void |
execute()
Sends the request immediately and blocks until the response can be processed or is an error.
|
com.apollographql.apollo.api.Operation |
operation()
Returns GraphQl operation this call executes
|
cancel, isCanceledvoid execute()
throws ApolloException
ApolloException - if the request could not be executed due to a cancellation, a timeout or a network
failurejava.lang.IllegalStateException - when the call has already been executed@Nonnull ApolloPrefetch enqueue(@Nullable ApolloPrefetch.Callback callback)
callback - Callback which will handle the success response or a failure exceptionjava.lang.IllegalStateException - when the call has already been executedApolloPrefetch clone()
@Nonnull com.apollographql.apollo.api.Operation operation()
Operation