ApolloStore.ReadWriteTransaction


CLASS

ApolloStore.ReadWriteTransaction

Swift
1public final class ReadWriteTransaction: ReadTransaction

Methods

update(_:_:)

Swift
1public func update<CacheMutation: LocalCacheMutation>(
2  _ cacheMutation: CacheMutation,
3  _ body: (inout CacheMutation.Data) throws -> Void
4) throws

updateObject(ofType:withKey:variables:_:)

Swift
1public func updateObject<SelectionSet: ApolloAPI.MutableRootSelectionSet>(
2  ofType type: SelectionSet.Type,
3  withKey key: CacheKey,
4  variables: GraphQLOperation.Variables? = nil,
5  _ body: (inout SelectionSet) throws -> Void
6) throws

write(data:for:)

Swift
1public func write<CacheMutation: LocalCacheMutation>(
2  data: CacheMutation.Data,
3  for cacheMutation: CacheMutation
4) throws

write(selectionSet:withKey:variables:)

Swift
1public func write<SelectionSet: MutableRootSelectionSet>(
2  selectionSet: SelectionSet,
3  withKey key: CacheKey,
4  variables: GraphQLOperation.Variables? = nil
5) throws

removeObject(for:)

Swift
1public func removeObject(for key: CacheKey) throws

Removes the object for the specified cache key. Does not cascade or allow removal of only certain fields. Does nothing if an object does not exist for the given key.

  • Parameters:

    • key: The cache key to remove the object for

Parameters

NameDescription
keyThe cache key to remove the object for

removeObjects(matching:)

Swift
1public func removeObjects(matching pattern: CacheKey) throws

Removes records with keys that match the specified pattern. This method will only remove whole records, it does not perform cascading deletes. This means only the records with matched keys will be removed, and not any references to them. Key matching is case-insensitive.

If you attempt to pass a cache path for a single field, this method will do nothing since it won't be able to locate a record to remove based on that path.

  • Note: This method can be very slow depending on the number of records in the cache. It is recommended that this method be called in a background queue.

  • Parameters:

    • pattern: The pattern that will be applied to find matching keys.

Parameters

NameDescription
patternThe pattern that will be applied to find matching keys.
Feedback

Edit on GitHub

Forums