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 |
---|---|
void |
cancel()
Cancels this
ApolloPrefetch . |
ApolloPrefetch |
clone()
Creates a new, identical ApolloPrefetch to this one which can be enqueued or executed even if this one has already
been executed.
|
void |
enqueue(ApolloPrefetch.Callback callback)
Schedules the request to be executed at some point in the future.
|
com.apollographql.apollo.api.Operation |
operation()
Returns GraphQL operation this call executes
|
isCanceled
void 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()
@NotNull com.apollographql.apollo.api.Operation operation()
Operation
void cancel()
ApolloPrefetch
. If the call has already completed, nothing will happen.
If the call is outgoing, an ApolloCanceledException
will be thrown if the call was started
with #execute()
. If the call was started with enqueue(Callback)
the ApolloPrefetch.Callback
will be disposed, and will receive no more events.
The call will attempt to abort and release resources, if possible.cancel
in interface Cancelable