public final class RealApolloStore extends java.lang.Object implements ApolloStore, ReadableStore, WriteableStore
ApolloStore.RecordChangeSubscriber
NO_APOLLO_STORE
Constructor and Description |
---|
RealApolloStore(NormalizedCache normalizedCache,
CacheKeyResolver cacheKeyResolver,
com.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters,
java.util.concurrent.Executor dispatcher,
com.apollographql.apollo.api.internal.ApolloLogger logger) |
Modifier and Type | Method and Description |
---|---|
CacheKeyResolver |
cacheKeyResolver() |
ResponseNormalizer<Record> |
cacheResponseNormalizer() |
ApolloStoreOperation<java.lang.Boolean> |
clearAll()
Clear all records from this
ApolloStore . |
java.util.Set<java.lang.String> |
merge(java.util.Collection<Record> recordSet,
CacheHeaders cacheHeaders) |
java.util.Set<java.lang.String> |
merge(Record record,
CacheHeaders cacheHeaders) |
ResponseNormalizer<java.util.Map<java.lang.String,java.lang.Object>> |
networkResponseNormalizer() |
NormalizedCache |
normalizedCache() |
void |
publish(java.util.Set<java.lang.String> changedKeys) |
java.util.Collection<Record> |
read(java.util.Collection<java.lang.String> keys,
CacheHeaders cacheHeaders) |
<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.internal.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.internal.ResponseFieldMapper<F> responseFieldMapper,
CacheKey cacheKey,
com.apollographql.apollo.api.Operation.Variables variables)
Read GraphQL fragment from store.
|
Record |
read(java.lang.String key,
CacheHeaders cacheHeaders) |
<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.Boolean> |
remove(CacheKey cacheKey,
boolean cascade)
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.
|
public RealApolloStore(@NotNull NormalizedCache normalizedCache, @NotNull CacheKeyResolver cacheKeyResolver, @NotNull com.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters, @NotNull java.util.concurrent.Executor dispatcher, @NotNull com.apollographql.apollo.api.internal.ApolloLogger logger)
public ResponseNormalizer<java.util.Map<java.lang.String,java.lang.Object>> networkResponseNormalizer()
networkResponseNormalizer
in interface ApolloStore
ResponseNormalizer
used to generate normalized records from the network.public ResponseNormalizer<Record> cacheResponseNormalizer()
cacheResponseNormalizer
in interface ApolloStore
ResponseNormalizer
used to generate normalized records from the cache.public void subscribe(ApolloStore.RecordChangeSubscriber subscriber)
subscribe
in interface ApolloStore
public void unsubscribe(ApolloStore.RecordChangeSubscriber subscriber)
unsubscribe
in interface ApolloStore
public void publish(@NotNull java.util.Set<java.lang.String> changedKeys)
publish
in interface ApolloStore
changedKeys
- A set of keys of Record
which have changed.@NotNull public ApolloStoreOperation<java.lang.Boolean> clearAll()
ApolloStore
ApolloStore
.clearAll
in interface ApolloStore
true
if all records was
successfully removed, false
otherwise@NotNull public ApolloStoreOperation<java.lang.Boolean> remove(@NotNull CacheKey cacheKey)
ApolloStore
remove
in interface ApolloStore
cacheKey
- of record to be removedtrue
if record with such key
was successfully removed, false
otherwise@NotNull public ApolloStoreOperation<java.lang.Boolean> remove(@NotNull CacheKey cacheKey, boolean cascade)
ApolloStore
remove
in interface ApolloStore
cacheKey
- of record to be removedcascade
- defines if remove operation is propagated to the referenced entitiestrue
if record with such key
was successfully removed, false
otherwise@NotNull public ApolloStoreOperation<java.lang.Integer> remove(@NotNull java.util.List<CacheKey> cacheKeys)
ApolloStore
remove
in interface ApolloStore
cacheKeys
- keys of records to be removedpublic <R> R readTransaction(Transaction<ReadableStore,R> transaction)
ApolloStore
readTransaction
in interface ApolloStore
R
- The result type of this read operation.transaction
- A code block to run once the read lock is acquired.public <R> R writeTransaction(Transaction<WriteableStore,R> transaction)
ApolloStore
writeTransaction
in interface ApolloStore
R
- The result type of this write operation.transaction
- A code block to run once the write lock is acquired.public NormalizedCache normalizedCache()
normalizedCache
in interface ApolloStore
NormalizedCache
which backs this ApolloStore.@Nullable public Record read(@NotNull java.lang.String key, @NotNull CacheHeaders cacheHeaders)
read
in interface ReadableStore
@NotNull public java.util.Collection<Record> read(@NotNull java.util.Collection<java.lang.String> keys, @NotNull CacheHeaders cacheHeaders)
read
in interface ReadableStore
@NotNull public java.util.Set<java.lang.String> merge(@NotNull java.util.Collection<Record> recordSet, @NotNull CacheHeaders cacheHeaders)
merge
in interface WriteableStore
public java.util.Set<java.lang.String> merge(Record record, @NotNull CacheHeaders cacheHeaders)
merge
in interface WriteableStore
public CacheKeyResolver cacheKeyResolver()
cacheKeyResolver
in interface ApolloStore
CacheKeyResolver
used for resolving field cache keys@NotNull public <D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> ApolloStoreOperation<T> read(@NotNull com.apollographql.apollo.api.Operation<D,T,V> operation)
ApolloStore
read
in interface ApolloStore
D
- type of GraphQL operation dataT
- type operation cached data will be wrapped withV
- type of operation variablesoperation
- to be read@NotNull public <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(@NotNull com.apollographql.apollo.api.Operation<D,T,V> operation, @NotNull com.apollographql.apollo.api.internal.ResponseFieldMapper<D> responseFieldMapper, @NotNull ResponseNormalizer<Record> responseNormalizer, @NotNull CacheHeaders cacheHeaders)
ApolloStore
read
in interface ApolloStore
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@NotNull public <F extends com.apollographql.apollo.api.GraphqlFragment> ApolloStoreOperation<F> read(@NotNull com.apollographql.apollo.api.internal.ResponseFieldMapper<F> responseFieldMapper, @NotNull CacheKey cacheKey, @NotNull com.apollographql.apollo.api.Operation.Variables variables)
ApolloStore
read
in interface ApolloStore
F
- type of fragment to be readresponseFieldMapper
- 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@NotNull public <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(@NotNull com.apollographql.apollo.api.Operation<D,T,V> operation, @NotNull D operationData)
ApolloStore
write
in interface ApolloStore
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@NotNull public <D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> ApolloStoreOperation<java.lang.Boolean> writeAndPublish(@NotNull com.apollographql.apollo.api.Operation<D,T,V> operation, @NotNull D operationData)
ApolloStore
Record
which have changed, that will notify any ApolloQueryWatcher
that depends on these Record
to re-fetch.writeAndPublish
in interface ApolloStore
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@NotNull public ApolloStoreOperation<java.util.Set<java.lang.String>> write(@NotNull com.apollographql.apollo.api.GraphqlFragment fragment, @NotNull CacheKey cacheKey, @NotNull com.apollographql.apollo.api.Operation.Variables variables)
ApolloStore
write
in interface ApolloStore
fragment
- data to be written to the storecacheKey
- CacheKey
to be used as root record keyRecord
which
have changed@NotNull public ApolloStoreOperation<java.lang.Boolean> writeAndPublish(@NotNull com.apollographql.apollo.api.GraphqlFragment fragment, @NotNull CacheKey cacheKey, @NotNull com.apollographql.apollo.api.Operation.Variables variables)
ApolloStore
Record
which have changed, that will notify any ApolloQueryWatcher
that depends on these Record
to re-fetch.writeAndPublish
in interface ApolloStore
fragment
- data to be written to the storecacheKey
- CacheKey
to be used as root record key@NotNull public <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(@NotNull com.apollographql.apollo.api.Operation<D,T,V> operation, @NotNull D operationData, @NotNull java.util.UUID mutationId)
ApolloStore
writeOptimisticUpdates
in interface ApolloStore
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@NotNull public <D extends com.apollographql.apollo.api.Operation.Data,T,V extends com.apollographql.apollo.api.Operation.Variables> ApolloStoreOperation<java.lang.Boolean> writeOptimisticUpdatesAndPublish(@NotNull com.apollographql.apollo.api.Operation<D,T,V> operation, @NotNull D operationData, @NotNull java.util.UUID mutationId)
ApolloStore
Record
s which have changed, that will
notify any that depends on these Record
to re-fetch.writeOptimisticUpdatesAndPublish
in interface ApolloStore
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@NotNull public ApolloStoreOperation<java.util.Set<java.lang.String>> rollbackOptimisticUpdates(@NotNull java.util.UUID mutationId)
ApolloStore
rollbackOptimisticUpdates
in interface ApolloStore
mutationId
- mutation unique identifier@NotNull public ApolloStoreOperation<java.lang.Boolean> rollbackOptimisticUpdatesAndPublish(@NotNull java.util.UUID mutationId)
ApolloStore
Record
s which have changed, that will
notify any that depends on these Record
to re-fetch.rollbackOptimisticUpdatesAndPublish
in interface ApolloStore
mutationId
- mutation unique identifierRecord
which
have changed