Skip to content

Latest commit

 

History

History
26 lines (24 loc) · 2.35 KB

getting-started.md

File metadata and controls

26 lines (24 loc) · 2.35 KB

Onboarding with DataStore

Understand the primary DataStore events

Building a sample app with DataStore to understand how it works

  1. Build a basic DataStore sample app (no @auth, just 1-2 models).
  2. Build a similar sample app with the API category.
  3. Add @auth rules to the DataStore app:
    1. amplify update api
    2. Modify schema according to auth rules docs (https://docs.amplify.aws/lib/datastore/setup-auth-rules/q/platform/js).
    3. amplify push
    4. amplify codegen models
  4. Add selective sync.
  5. Enable real-time changes.
  6. While interacting with your app, examine the IndexedDB tables (Application > IndexedDB within Chrome dev tools):
    1. Check out the different stores in IDB that get created for your schema. Note the internal stores prefixed with sync_, and the stores corresponding to your models prefixed with user_.
    2. Familiarize yourself with how actions taken in the UI affect the data stored in IDB. This may be easier to do while throttling the network connection. You'll be able to see how outgoing mutations first get persisted into the corresponding store, then added to the mutation queue / outbox (sync_MutationEvent), and then updated in the store with data from AppSync.
  7. Turn on DEBUG logging (ConsoleLogger.LOG_LEVEL = "DEBUG";) at the root of your project, and inspect the logs in the console while using your app. Additionally, enable hub events for DataStore.
  8. The best way to understand DataStore events is to place several debuggers or breakpoints throughout DataStore.
    • With logging / Hub events enabled, you can see what operations DataStore is performing (i.e. start, sync, etc.) as you step through with the debugger.
  9. Testing offline scenerios / concurrent user sessions is a useful way to test the full functionality of DataStore, and to fully understand how the sync process actually works.
  10. Next steps:
    • Create a React Native example (uses a different storage type)
    • Try more complex schema types
    • Observe changes in records within DynamoDB (for instance, soft deletion).