Sitemap

Offline-first made easy with GraphQL, Amplify DataStore and Vue

15 min readOct 1, 2020

--

Press enter or click to view image in full size

GraphQL knowledge is beneficial when using Amplify DataStore to understand its inner workings but not necessary to use DataStore APIs.

Press enter or click to view image in full size
Amplify DataStore data flow in offline mode
Press enter or click to view image in full size
Amplify DataStore data flow in online mode

It’s important that you don’t miss the following steps to set up conflict detection. If you missed it, you can recover with amplify api update

Press enter or click to view image in full size

Using data models allow us to be always compliant with the GraphQL schema and prevent errors right in the client.

When using Amplify DataStore records are never removed, but marked for removal. Records will then be automatically removed as defined in their TTL attribute. At the time of writing, this is set to 30 days.

As we are using Amplify DataStore, as our source of truth, we don’t need another copy of it at the app level so we just need to load the latest state with loadMessages.

Press enter or click to view image in full size
Real-time synchronisation using Chrome and Firefox clients side-by-side.
Press enter or click to view image in full size
Service worker serving assets from the cache while offline

Learn more about service workers at using service workers.

Remember that in order to test the app you need to install the service worker first. This requires at least loading the app once.

Press enter or click to view image in full size
Chatty app while offline.
Chatty PWA informing the user of changes in the network status.
Press enter or click to view image in full size
AWS Amplify Console deployment steps.
Press enter or click to view image in full size
Use add to Home screen to install in Desktop and Mobile.

--

--

Gerard Sans
Gerard Sans

Helping Devs to succeed #AI #web3 / ex @AWSCloud / Just be AWSome / MC Speaker Trainer Community Leader @web3_london / @ReactEurope @ReactiveConf @ngcruise