amplify-flutter icon indicating copy to clipboard operation
amplify-flutter copied to clipboard

Amplify Gen 2 - No offline-first support

Open rathoregee opened this issue 5 months ago • 5 comments

Description

Does Amplify Gen 2 support DataStore?

How do we achieve local storage, such as offline-first?

How do we store some models locally and some synced with the cloud? For example, you have standard and premium membership features in the app

Please help me with Amplify Gen 2. How do we achieve offline-first?

Categories

  • [ ] Analytics
  • [ ] API (REST)
  • [x] API (GraphQL)
  • [ ] Auth
  • [ ] Authenticator
  • [x] DataStore
  • [ ] Notifications (Push)
  • [x] Storage

Steps to Reproduce

Amplify Gen 2 supports GraphQL APIs without DataStore.

Screenshots

Too many sync conflicts coming after call await Amplify.DataStore.start();

await Amplify.addPlugins([ AmplifyAPI(), AmplifyAuthCognito(), AmplifyDataStore(modelProvider: ModelProvider.instance), ]);

Platforms

  • [x] iOS
  • [x] Android
  • [ ] Web
  • [ ] macOS
  • [ ] Windows
  • [ ] Linux

Flutter Version

3.32.0

Amplify Flutter Version

2.4.0

Deployment Method

Amplify Gen 2

Schema


rathoregee avatar Jul 02 '25 22:07 rathoregee

Hi @rathoregee, for local storage, sqflite and drift are two commonly used libaries (we use drift as a dependency already in Amplify Flutter, so ensure versions are resolved if using this). As for part local and part cloud synced models, this would require writing separate models in your offline solution that correspond to Amplify GraphQL models, then writing code for remote sync once the device is connected to the internet. For this you can use the Amplify GraphQL API subscribe functions, so long as your models are compliant with what GraphQL expects. There's a great guide on the Android docs about writing offline first apps

ekjotmultani avatar Jul 03 '25 20:07 ekjotmultani

E/amplify:aws-datastore( 4819): at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.kt:307) W/amplify:aws-datastore( 4819): at com.amplifyframework.datastor I/amplify:aws-datastore( 4819): Orchestrator transitioning from SYNC_VIA_API to LOCAL_ONLY

How to swallow E/I/W ? execeptions, info , warning from aws-datastore in flutter dart .. any idea

rathoregee avatar Jul 05 '25 21:07 rathoregee

Hello @rathoregee, we have an open feature request to add additional logging customization, such as disabling platform/category specific logging. In the meantime if your IDE supports it you can use exclude filters such as !E/amplify, !W/amplify, !I/amplify

VSCode Debug Console without filter: Image

VSCode Debug Console with filter:

Image

tyllark avatar Jul 07 '25 21:07 tyllark

is there a way from code you can not throw on console

rathoregee avatar Jul 11 '25 08:07 rathoregee

Hello @rathoregee, unfortunately we do not have that feature at this time. The feature request I linked above would cover that use case.

tyllark avatar Jul 11 '25 18:07 tyllark