Postico local cache11/3/2022 ![]() Removes all objects with a CacheKey that matches the given pattern. ![]() Removes a single object for the given CacheKey. Removes all data from the cache immediately. There are presently three deletion methods available: Once you have generated mutable query models, you can use them with ReadWriteTransaction.update(). Writing local cache mutations to the cache Instead, define mutable fragments or queries to mutate only the necessary fields. You should avoid creating mutable versions of entire query operations. By maintaining immutable models, we avoid any confusion this could cause.Ĭache mutations are designed to be narrowly scoped to access and mutate only the necessary data. Additionally, if the models were mutable, mutating them outside of a ReadWriteTransaction would not persist any changes to the cache. Because network response data is immutable and cache mutation models are mutable, you must use seperate models.īecause mutable data requires a lot more generated code, generating mutable models for all operations would nearly double the size of the generated operations. This means they cannot be sent as query operations to your server using an ApolloClient. The generated models for queries defined as cache mutations will conform to LocalCacheMutation, but not GraphQLQuery. Seperating Cache Mutations from Network Operations POSTICO LOCAL CACHE CODEIn order to write to the cache, you can define a LocalCacheMutation.Ī LocalCacheMutation is just a GraphQL query or fragment definition that has been flagged as a local cache mutation using the Apollo iOS specific directive a query or fragment with this directive is defined, the code generation engine will generate a mutable model that can be used with a ReadWriteTransaction to write data to the cache. However, because the generated models for your operations and fragments are immutable, you cannot change the values on these models to write them to the cache. Like reading cache data, writing to the cache uses type-safe generated models. To write data to the cache, you'll need to define a LocalCacheMutation. In addition the the ability to write data to the cache, ReadWriteTransaction has all of the functionality of a ReadTransaction. ![]() The transaction block provides a ReadWriteTransaction. You can write data to the local cache with ApolloStore.withinReadWriteTransaction(_:callbackQueue:completion:). ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |