amplify-flutter
amplify-flutter copied to clipboard
Conflict handler not called for conflicts created while offline
Description
It seems as though amplify in optimistic concurrency mode is not triggering the conflictHandler method when conflicts are created while offline. I have tested on android but not on iOS, although I'd be surprised if this was related to a specific platform.
Categories
- [ ] Analytics
- [ ] API (REST)
- [X] API (GraphQL)
- [ ] Auth
- [ ] Authenticator
- [ ] DataStore
- [ ] Notifications (Push)
- [ ] Storage
Steps to Reproduce
In our testing we have a model with a "name" field. That name field can also be edited through a REST endpoint which calls a lambda (or alternatively be modified through AppSync). So our test scenario goes as follows:
The name field starts as "joe". We go offline in the app and change the field to "mary" We update the name through our REST endpoint to be "frank" We go online in the app.
We were expecting the conflictHandler method, in the AmplifyDataStore options, to be called but it isn't. Instead the name is set to "mary" and the version is increased as if the app was simply pushing the changes and ignoring the version the change was made in. Does amplify not store and respect the version in which the changes were made on? Is there a different way of resolving this kind of conflict?
Screenshots
No response
Platforms
- [ ] iOS
- [X] Android
- [ ] Web
- [ ] macOS
- [ ] Windows
- [ ] Linux
Flutter Version
12.12.4
Amplify Flutter Version
2.1.0
Deployment Method
Amplify CLI
Schema
I've removed some properties of the schema and only left the relevant property described, "name".
type User
@model
@auth(
rules: [
{ allow: owner, ownerField: "userId" }
{ allow: private, provider: iam }
]
) {
userId: ID! @primaryKey @auth(
rules: [
{ allow: groups, groups: ["FORBIDDEN"], operations: [update, delete] }
{ allow: owner, ownerField: "userId", operations: [create, read] }
{ allow: private, provider: iam }
]
)
name: String!
}