Closed arnaudcisse closed 1 year ago
Hi, @arnaudcisse
Thanks for reaching out.
I tried out the code snippet you provided to get and update a model instance, it works for me. Can you double confirm that the get and update dose not work on your App?
Can you make sure several things?
Todo
instance with the ID you try to retrieve exists?If the problem persists, can you provide more information? Like which Amplify version are you using? Which device are you using? How did you provision the backend? etc. Thanks
Hi ruigoamz,
So I think I solved the issue, it had to follow this thread: https://github.com/aws-amplify/amplify-cli/issues/4111
Basically, I think I could not update because I did not provide a version number. And amplify sent a success message, but the todo description was not updated. So following the thread, I removed the api, then added it again but disabling the datastore and removing the conflict description and now the todo descriptions are updating.
I think there should be some error message pointing this out. Let me know if you can't reproduce the issue!
Leaving this open so @aws-amplify/ios-team can review docs. The _version
requirement should only be in place when the API has conflict resolution enabled, which is typically something we do for DataStore. However, if a customer enables conflict resolution and continues to use the API category, we need to ensure that we've properly guided customers to provide a _version
.
I want to know why we need to retrieve the Item with a query just to update a parameter? It seems a bit silly. Why can't I just pass the item id and the parameter I want to update??? I understand you guys build this stuff to work with a local datastore but please understand that not everybody wants to give up complete client side control of their app. I just want to simply update one field in my database and for that I have to do it in two parts. Firstly to send a query to retrieve the entire item and then secondly modify one field and then do an update mutation. Makes no sense.
@alionthego you can read here a quite detailed explanation about why at the moment providing the full model is necessary.
thanks for the link to the explanation. It's still not clear why this can't be done with some logic in the SDK. Currently you can modify one field only from a lambda function. In any case thanks for the link
Leaving this open for the amplify team to update the doc as mentioned https://github.com/aws-amplify/amplify-ios/issues/1075#issuecomment-789112124
Hello, I am really struggling to run an update mutation on swift ios with amplify AWS (GraphQL API)
I am sure this question will help a lot of beginners on AWS, as it is directly related to the tutorial.
The tutorial from: (https://docs.amplify.aws/lib/graphqlapi/mutate-data/q/platform/ios)](url) says that to update/create a todo, you should:
So I understand that I first need to get the todo using a get (with an ID) or a list (with a predicate) query, then updating, so something along the line of the following:
However that does not work, do you know what I am doing wrong (the todo has the same description, it has not been updated!)
Many thanks for someone that can help me and please update the tutorial on AWS amplify!
Which AWS Services are you utilizing? Amplify GraphQL API
Provide code snippets (if applicable)
Environment(please complete the following information):
Device Information (please complete the following information): iOS