-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating model attribute using Amplify.API.Query #3526
Comments
@ip5038 Thanks for raising the issue. Our team will look into the issue and provide an update as soon as we can. |
I wasn't able to find the fix for this issue, but the workaround to this is using a custom lambda conflict resolver. Add a custom lambda resolver via amplify cli and you can configure how you want to deal with conflicts. In my case, I just resolved the conflict without doing checks for versions or anything. Amplify docs has information on how to setup custom lambda resolver. |
Hello, Do you know the Amplify version being used? When you save the model after the update, are you seeing any errors being logged into the console? Are you able to receive You can use It'd be great if you could attach the logs in the issue after removing sensitive information. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
I'm fetching a model via Amplify.API.query and updating one of the model attributes. Then I'm saving that model again, but it doesn't update the attribute.
Here is what happens
Mutation is triggered by user clicking on a button. On each click Amplify.Datastore.save(theModel) is called.
The model I am trying to do this on has secondary index, but I also have another model (which doesn't have secondary index) and it doesn't work either. I update both models in the same way, but no luck.
I am not comfortable sharing the schema. So here is a sample schema with the same structure and GSI setup
enum MyEnum {
Enum_Val_A
Enum_Val_B
Enum_Val_C
Enum_Val_D
}
type MyModel @model @auth(rules: [{allow: public}]) {
id: ID!
attribute_A: ID! @index(name: "myGSI", sortKeyFields: ["attribute_C"], queryField: "myQueryField")
attribute_B: ID!
attribute_C: MyEnum
attribute_D: ID
}
What I have tried to fix
I have conflict resolution enabled . I tried auto-merge, optimistic, and disabled the conflict resolution but same issue each time.
Steps To Reproduce
Expected behavior
The attribute on the model fetched via Amplify.API.query should be updated on first try.
Amplify Framework Version
12.6.0
Amplify Categories
API, DataStore
Dependency manager
Cocoapods
Swift version
6.9.2
CLI version
12.6.0
Xcode version
Version 15.2 (15C500b)
Relevant log output
No response
Is this a regression?
No
Regression additional context
No response
Platforms
iOS
OS Version
iOS 17.0
Device
iPhone 15 Pro Simulator
Specific to simulators
No. It happens on real device as well.
Additional context
No response
The text was updated successfully, but these errors were encountered: