public interface ApolloStore
NormalizedCache.
It also maintains a list of ApolloStore.RecordChangeSubscriber that will be notified with changed records.
Most clients should have no need to directly interface with an ApolloStore.| Modifier and Type | Interface and Description |
|---|---|
static interface |
ApolloStore.RecordChangeSubscriber
Listens to changed record keys dispatched via
publish(Set). |
| Modifier and Type | Field and Description |
|---|---|
static ApolloStore |
NO_APOLLO_STORE |
| Modifier and Type | Method and Description |
|---|---|
CacheKeyResolver |
cacheKeyResolver() |
ResponseNormalizer<Record> |
cacheResponseNormalizer() |
ApolloStoreOperation<java.lang.Boolean> |
clearAll()
Clear all records from this
ApolloStore. |
ResponseNormalizer<java.util.Map<java.lang.String,java.lang.Object>> |
networkResponseNormalizer() |
NormalizedCache |
normalizedCache() |
void |
publish(java.util.Set<java.lang.String> keys) |
<D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> |
read(com.apollographql.apollo.api.Operation<D,T,V> operation)
Read GraphQL operation from store.
|
<D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> |
read(com.apollographql.apollo.api.Operation<D,T,V> operation,
com.apollographql.apollo.api.ResponseFieldMapper<D> responseFieldMapper,
ResponseNormalizer<Record> responseNormalizer,
CacheHeaders cacheHeaders)
Read GraphQL operation response from store.
|
<F extends com.apollographql.apollo.api.GraphqlFragment> |
read(com.apollographql.apollo.api.ResponseFieldMapper<F> fieldMapper,
CacheKey cacheKey,
com.apollographql.apollo.api.Operation.Variables variables)
Read GraphQL fragment from store.
|
<R> R |
readTransaction(Transaction<ReadableStore,R> transaction)
Run a operation inside a read-lock.
|
ApolloStoreOperation<java.lang.Boolean> |
remove(CacheKey cacheKey)
Remove cache record by the key
|
ApolloStoreOperation<java.lang.Integer> |
remove(java.util.List<CacheKey> cacheKeys)
Remove cache records by the list of keys
|
ApolloStoreOperation<java.util.Set<java.lang.String>> |
rollbackOptimisticUpdates(java.util.UUID mutationId)
Rollback operation data optimistic updates.
|
ApolloStoreOperation<java.lang.Boolean> |
rollbackOptimisticUpdatesAndPublish(java.util.UUID mutationId)
|
void |
subscribe(ApolloStore.RecordChangeSubscriber subscriber) |
void |
unsubscribe(ApolloStore.RecordChangeSubscriber subscriber) |
ApolloStoreOperation<java.util.Set<java.lang.String>> |
write(com.apollographql.apollo.api.GraphqlFragment fragment,
CacheKey cacheKey,
com.apollographql.apollo.api.Operation.Variables variables)
Write fragment to the store.
|
<D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> |
write(com.apollographql.apollo.api.Operation<D,T,V> operation,
D operationData)
Write operation to the store.
|
ApolloStoreOperation<java.lang.Boolean> |
writeAndPublish(com.apollographql.apollo.api.GraphqlFragment fragment,
CacheKey cacheKey,
com.apollographql.apollo.api.Operation.Variables variables)
Write fragment to the store and publish changes of
Record which have changed, that will notify any ApolloQueryWatcher that depends on these Record to re-fetch. |
<D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> |
writeAndPublish(com.apollographql.apollo.api.Operation<D,T,V> operation,
D operationData)
Write operation to the store and publish changes of
Record which have changed, that will notify any ApolloQueryWatcher that depends on these Record to re-fetch. |
<D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> |
writeOptimisticUpdates(com.apollographql.apollo.api.Operation<D,T,V> operation,
D operationData,
java.util.UUID mutationId)
Write operation data to the optimistic store.
|
<D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> |
writeOptimisticUpdatesAndPublish(com.apollographql.apollo.api.Operation<D,T,V> operation,
D operationData,
java.util.UUID mutationId)
|
<R> R |
writeTransaction(Transaction<WriteableStore,R> transaction)
Run a operation inside a write-lock.
|
static final ApolloStore NO_APOLLO_STORE
void subscribe(ApolloStore.RecordChangeSubscriber subscriber)
void unsubscribe(ApolloStore.RecordChangeSubscriber subscriber)
void publish(java.util.Set<java.lang.String> keys)
keys - A set of keys of Record which have changed.@Nonnull ApolloStoreOperation<java.lang.Boolean> clearAll()
ApolloStore.true if all records was
successfully removed, false otherwise@Nonnull ApolloStoreOperation<java.lang.Boolean> remove(@Nonnull CacheKey cacheKey)
cacheKey - of record to be removedtrue if record with such key
was successfully removed, false otherwise@Nonnull ApolloStoreOperation<java.lang.Integer> remove(@Nonnull java.util.List<CacheKey> cacheKeys)
cacheKeys - keys of records to be removedResponseNormalizer<java.util.Map<java.lang.String,java.lang.Object>> networkResponseNormalizer()
ResponseNormalizer used to generate normalized records from the network.ResponseNormalizer<Record> cacheResponseNormalizer()
ResponseNormalizer used to generate normalized records from the cache.<R> R readTransaction(Transaction<ReadableStore,R> transaction)
R - The result type of this read operation.transaction - A code block to run once the read lock is acquired.<R> R writeTransaction(Transaction<WriteableStore,R> transaction)
R - The result type of this write operation.transaction - A code block to run once the write lock is acquired.NormalizedCache normalizedCache()
NormalizedCache which backs this ApolloStore.CacheKeyResolver cacheKeyResolver()
CacheKeyResolver used for resolving field cache keys@Nonnull <D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> ApolloStoreOperation<T> read(@Nonnull com.apollographql.apollo.api.Operation<D,T,V> operation)
D - type of GraphQL operation dataT - type operation cached data will be wrapped withV - type of operation variablesoperation - to be read@Nonnull <D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> ApolloStoreOperation<com.apollographql.apollo.api.Response<T>> read(@Nonnull com.apollographql.apollo.api.Operation<D,T,V> operation, @Nonnull com.apollographql.apollo.api.ResponseFieldMapper<D> responseFieldMapper, @Nonnull ResponseNormalizer<Record> responseNormalizer, @Nonnull CacheHeaders cacheHeaders)
D - type of GraphQL operation dataT - type operation cached data will be wrapped withV - type of operation variablesoperation - response of which should be readresponseFieldMapper - ResponseFieldMapper to be used for field mappingresponseNormalizer - ResponseNormalizer to be used when reading cached responsecacheHeaders - CacheHeaders to be used when reading cached response@Nonnull <F extends com.apollographql.apollo.api.GraphqlFragment> ApolloStoreOperation<F> read(@Nonnull com.apollographql.apollo.api.ResponseFieldMapper<F> fieldMapper, @Nonnull CacheKey cacheKey, @Nonnull com.apollographql.apollo.api.Operation.Variables variables)
F - type of fragment to be readfieldMapper - ResponseFieldMapper to be used for field mappingcacheKey - CacheKey to be used to find cache record for the fragmentvariables - Operation.Variables required for fragment arguments resolving@Nonnull <D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> ApolloStoreOperation<java.util.Set<java.lang.String>> write(@Nonnull com.apollographql.apollo.api.Operation<D,T,V> operation, @Nonnull D operationData)
D - type of GraphQL operation dataT - type operation cached data will be wrapped withV - type of operation variablesoperation - Operation response data of which should be written to the storeoperationData - Operation.Data operation response data to be written to the storeRecord which
have changed@Nonnull <D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> ApolloStoreOperation<java.lang.Boolean> writeAndPublish(@Nonnull com.apollographql.apollo.api.Operation<D,T,V> operation, @Nonnull D operationData)
Record which have changed, that will notify any ApolloQueryWatcher that depends on these Record to re-fetch.D - type of GraphQL operation dataT - type operation cached data will be wrapped withV - type of operation variablesoperation - Operation response data of which should be written to the storeoperationData - Operation.Data operation response data to be written to the store@Nonnull ApolloStoreOperation<java.util.Set<java.lang.String>> write(@Nonnull com.apollographql.apollo.api.GraphqlFragment fragment, @Nonnull CacheKey cacheKey, @Nonnull com.apollographql.apollo.api.Operation.Variables variables)
@Nonnull ApolloStoreOperation<java.lang.Boolean> writeAndPublish(@Nonnull com.apollographql.apollo.api.GraphqlFragment fragment, @Nonnull CacheKey cacheKey, @Nonnull com.apollographql.apollo.api.Operation.Variables variables)
Record which have changed, that will notify any ApolloQueryWatcher that depends on these Record to re-fetch.fragment - data to be written to the storecacheKey - CacheKey to be used as root record key{@link - Operation.Variables} required for fragment arguments resolving@Nonnull <D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> ApolloStoreOperation<java.util.Set<java.lang.String>> writeOptimisticUpdates(@Nonnull com.apollographql.apollo.api.Operation<D,T,V> operation, @Nonnull D operationData, @Nonnull java.util.UUID mutationId)
operation - Operation response data of which should be written to the storeoperationData - Operation.Data operation response data to be written to the storemutationId - mutation unique identifierRecord which
have changed@Nonnull <D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> ApolloStoreOperation<java.lang.Boolean> writeOptimisticUpdatesAndPublish(@Nonnull com.apollographql.apollo.api.Operation<D,T,V> operation, @Nonnull D operationData, @Nonnull java.util.UUID mutationId)
Records which have changed, that will
notify any that depends on these Record to re-fetch.operation - Operation response data of which should be written to the storeoperationData - Operation.Data operation response data to be written to the storemutationId - mutation unique identifier@Nonnull ApolloStoreOperation<java.util.Set<java.lang.String>> rollbackOptimisticUpdates(@Nonnull java.util.UUID mutationId)
mutationId - mutation unique identifier@Nonnull ApolloStoreOperation<java.lang.Boolean> rollbackOptimisticUpdatesAndPublish(@Nonnull java.util.UUID mutationId)
Records which have changed, that will
notify any that depends on these Record to re-fetch.mutationId - mutation unique identifierRecord which
have changed