1

I am developing an Android and iOS app that could be used in areas that have a very poor or no data connection. It is a requirement for the app to be pre-loaded with all of the data so it will work even if the app never communicated with the server, but it also needs to be able to update and sync when a connection is made. Is it possible to manually populate the AppSync (Apollo) cache database with data on launch and query and mutate it later? The app also contains several search and filter queries. Our backend API is currently using GraphQL.

I have seen this question, Is it possible to build offline-first mobile apps using AWS AppSync?, but it is a little different that what I'm asking.

Mark
  • 1,130
  • 3
  • 17
  • 32

1 Answers1

0

The recommendation would be to hydrate (read: pre-load with data) a local SQLite database after install. SQLite is what the 'local cache' uses to persist data on the device.

Refer to this github issue for a code example of how to do this: https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/160

  • Thanks, but I will be using the native Android and iOS SDKs. I'm not seeing hydrate or restore methods on the client like I do in the js SDK. I am trying to see if I can just use Apollo's internal SQLite db for caching instead of creating my own, that seems like duplicated data. Since the app contains several uncachable queries, like search queries, managing my own cache db may be the only way to go anyway. Maybe I'm missing something? – Mark Jun 26 '19 at 14:38
  • @Mark Did you ever solve this problem? I am also looking at using appsync for an app that will primarily be offline – Joseph Devlin Jan 27 '21 at 11:22
  • @JosephDevlin I ended up just using a local SQLite database with preloaded data. I fetch new data with AppSync to update the database and query the database directly for the data. – Mark Jan 27 '21 at 13:35
  • @Mark I really appreciate you answering my question after so long. I hope you don't mind if I ask you another. Did you run into any difficulty with having your sqlite database and the appsync offline store going out of sync? – Joseph Devlin Jan 27 '21 at 16:49
  • @JosephDevlin No problem! I am using the SQLite database for everything and not using the AppSync offline store or anything, so there is only one source of data. – Mark Jan 28 '21 at 13:34
  • @Mark so you are essentially using appsync as just a vehicle for real time data updates and pushing up changes? Other than that, you manage all the data in your app via the SQLite database? That is similar to a strategy i'm planning to use but im wondering if you ran into any conflict issues when taking new data from your appsync and putting it into your SQLite db? – Joseph Devlin Oct 29 '21 at 12:37