Migrate from DataStore
Understanding DataStore
AWS Amplify DataStore provided a local-first data layer that automatically synchronized data between your app and the cloud. When you used DataStore, you got several powerful capabilities without writing any synchronization logic yourself: a local database that persisted data across sessions, automatic bidirectional sync with your AppSync backend, built-in conflict resolution using version tracking, full offline support with mutation queuing and replay, and real-time updates through observe() and observeQuery().
DataStore abstracted away the complexity of GraphQL operations, network state management, and data consistency. You worked with simple save, query, and delete methods on local models, and DataStore handled everything else behind the scenes.
This guide shows you how to migrate from DataStore to Apollo Kotlin and the AWS AppSync Apollo Extensions library for queries, mutations, and subscriptions. Depending on how much of DataStore's feature set your app actually uses, you may find the migration simpler than expected.
Once frontend clients have been migrated off DataStore, disable conflict resolution on the backend to remove the sync infrastructure, simplify mutations (no more _version tracking), and switch from soft deletes to hard deletes.
What this guide covers
This guide walks you through the migration path from DataStore to Apollo Kotlin. You will set up Apollo Kotlin with your AppSync endpoint, migrate all CRUD operations, and optionally add local caching and offline-first support.
Quick comparison: before and after
Here is a quick look at how common DataStore operations translate to Apollo Kotlin:
| DataStore Operation | Apollo Kotlin Equivalent |
|---|---|
Amplify.DataStore.save() | Apollo mutations (CreatePostMutation, UpdatePostMutation) |
Amplify.DataStore.delete() | Apollo mutations (DeletePostMutation) |
Amplify.DataStore.query() | Apollo queries (GetPostQuery, GetPostsQuery) |
Amplify.DataStore.observe() | Apollo subscriptions (OnCreateSubscription, etc.) via toFlow() |
Amplify.DataStore.observeQuery() | Apollo normalized cache + watch() |
Amplify.DataStore.clear() | No longer needed (no local DataStore to clear) |
Amplify.DataStore.start() / stop() | No longer needed |
Use cases
Not all customers need the full extent of DataStore's capabilities. Depending on your specific use case, migration can be straightforward:
- Local caching: If you used DataStore primarily as a local caching layer, storing data temporarily on the device but not relying heavily on its offline-first capabilities, Apollo Kotlin can provide lightweight data caching without the complexities of managing full offline sync, making it a good fit if your application is mostly connected and only occasionally requires offline access.
- Offline-first: If your business requirements rely on fully supporting offline-first functionality, the offline-first guide provides a high-level approach for migrating to a new offline-first solution.
How to use this guide
Follow the pages in order. Each step builds on the previous one.
-
Remove DataStore. Remove the DataStore dependency and plugin from your project.
-
Schema and GraphQL operations. Retrieve your AppSync schema and define your GraphQL operations for Apollo code generation.
-
Set up Apollo Kotlin. Add dependencies, configure the Gradle plugin, and set up the Apollo client with your AppSync endpoint and authentication.
-
Migrate DataStore to Apollo. Replace all DataStore operations with Apollo equivalents. Migrate
save,query,delete,observe, andobserveQuery. -
Optional: Local caching. Set up a local cache using Apollo's normalized cache or a custom caching layer with Room.
-
Offline-first. Build full offline support with remote sync, live syncing, network detection, and offline mutations.
-
Disable conflict resolution. Once ALL frontend clients are migrated off DataStore, remove the sync infrastructure, simplify mutations, and switch from soft deletes to hard deletes.
-
Helpful resources. Additional documentation, third-party packages, and references.
Migration checklist
Use this checklist to plan and track your migration:
- Remove the DataStore dependency — Remove
com.amplifyframework:aws-datastorefrom yourbuild.gradle.kts(see Remove DataStore) - Remove the DataStore plugin — Remove
AWSDataStorePlugin()from yourAmplify.addPlugin()calls - Delete generated model files — Remove DataStore-generated model classes
- Set up schema and operations — Retrieve your AppSync schema and define GraphQL operations (see Schema and GraphQL operations)
- Set up Apollo Kotlin — Add dependencies and configure the Apollo client (see Set up Apollo Kotlin)
- Migrate CRUD operations — Replace
DataStore.save(),DataStore.query(), andDataStore.delete()with Apollo equivalents (see Migrate DataStore to Apollo) - Migrate real-time listeners — Replace
DataStore.observe()andDataStore.observeQuery()with Apollo subscriptions and cache watchers - Test — Verify all CRUD operations, real-time subscriptions, and error handling
- Disable conflict resolution — Once all clients are migrated (see Disable conflict resolution)