Closed enggazzar closed 9 months ago
There is no such thing at the moment. You can mutate your cache locally but if you need that mutation to reach your server, you need to save it using something like WorkManager
@enggazzar anything else we can help with here?
Thanks but at least I can execute mutation offline the only example is https://www.apollographql.com/docs/kotlin/caching/store/ ?
Yes, that's correct, the ApolloStore
API allows you to write data to the store offline and you can synchronize that later.
If you're looking at a more concrete example, you can take a look at our benchmarks. They use writeOperation
here
writeOperation is this mean execute mutation offline the task I have is operation with cart like add to cart remove from cart is this possible to work offline?
writeOperation
updates the contents of your local, offline, cache with the data
that you are passing as argument.
Most of the time, you don't need a mutation to write your local cache: create a Query.data
instance programmatically and pass it to writeOperation
. In your example, something like writeOperation(cartContentsQuery, CartsContentQuery(items = listOf(newItemHere)), customScalarAdapters)
.
There's no silver bullet though and if you want that cart content to be synchronized to the backend, you'll have to execute the mutation later on.
Hi 👋 I'll close this one in favour of https://github.com/apollographql/apollo-kotlin/issues/5618. That's something that would be nice to have although it's probably not for the short term.
Sure Thanks for your help
On Mon, Feb 12, 2024 at 11:21 AM Martin Bonnin @.***> wrote:
Hi 👋 I'll close this one in favour of #5618 https://github.com/apollographql/apollo-kotlin/issues/5618. That's something that would be nice to have although it's probably not for the short term.
— Reply to this email directly, view it on GitHub https://github.com/apollographql/apollo-kotlin/issues/5548#issuecomment-1938296889, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZH7W2G6NNLPOPFNHOM2IDYTHNJRAVCNFSM6AAAAABCDHSL56VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZYGI4TMOBYHE . You are receiving this because you were mentioned.Message ID: @.***>
Question
I need to add items to the cart while there is no internet connection and when the mobile has internet mutation executed