Closed zamargab closed 2 years ago
@zamargab in addition to ensuring the record has been synced (like you mentioned) you have to keep in mind that any backend w datastore has conflict resolution enabled. To modify records with conflict resolution enabled, you won't be able to use graphql model helpers like ModelMutations.update
because they will not include conflict resolution fields. Those fields are not included in codegen models by design. You can have a look at a workaround described in an open feature request https://github.com/aws-amplify/amplify-flutter/issues/1434#issuecomment-1062123160 to see if it helps here.
Also, do you mind posting here the error you are getting from your code above?
Does this mean if I remove conflict resolutions, I will be able make update to records via API? and what are the implications of removing conflict resolution?
You can update via API with conflict resolution enabled, you just have to go through extra effort to send update with correct value for _version as mentioned in aforementioned code example workaround. If you disable conflict resolution, you would be able to update with API more easily (won't need to include _version and model helpers should work) but you would then not be able to use datastore as datastore depends on using conflict resolution on the backend. If you want to use both datastore and API, the only option is to enable conflict resolution and manually format the requests to include _version that matches latest from server.
Hello @zamargab while manually inserting conflict detection meta fields _version
, _delete
is being required to make API GraphQL and DataStore working together, we are investigating improved support of your use case.
I'm closing this issue in favor of https://github.com/aws-amplify/amplify-flutter/issues/1434 , we will be updating progress on this linked issue. Please feel free to follow up if anything.
Description
I have Datastore and API configured in my application, I need to update records as soon as app is installed, I tried using code below but it returns an error because Datastore needs time to sync local and cloud database at the time app is installed.
is there anyway I can update records via API without making reference to the time through datastore?
Categories
Steps to Reproduce
Screenshots
No response
Platforms
Android Device/Emulator API Level
No response
Environment
Dependencies
Device
Iphone 12
OS
iOS 15.5
CLI Version
8.4.0
Additional Context
No response