apollo-kotlin
apollo-kotlin copied to clipboard
Automatic off-line / on-line status detection and data sync
Use case I'm using GraphQL Kotlin and the device becomes off-line. In such case the library could gather the changes and when the network is available again it could sync the changes to the server. The idea would be that the library user would not have to care about the network status and won't have to do any weight lifting for it (so essentially the functionality would be transparent). This question arise during Benoit Lubek and Martin Bonnin's session about GraphQL Kotlin caching at Android Worldwide conference April 19th.
Describe the solution you'd like This scenario is relevant only if the GraphQL data / source is sitting at a remote server. This would require a detection if the network connection is available or not (this is hard topic, Android may provide some facilities for that). Also would need a way to mark changes gathered during off-line status. Then there would be a sync and as Benoit (or Martin) pointed out merge conflicts could arise.
I'm not 100% sure if the library is the right place for this, for example AWS AppSync (https://aws.amazon.com/blogs/mobile/aws-appsync-offline-reference-architecture/) use GraphQL under the hood already. However a vendor independent solution would mean less fear of vendor lock-in.
Another technology I know which provides transparent off/on line syncing is Firestore's data handling, I don't know the details about what's the actual way these solve merge conflicts. Maybe last write wins? This would need some modification timestamp as well. I know times can be skewed, I guess an imperfect solution is good already.