Search code examples
amazon-web-servicesamazon-dynamodbaws-appsync

AppSync Batch Update Item?


According to the documentation, it seems like AppSync doesn't support BatchUpdateItem (only supports BatchPutItem and BatchGetItem). I have a use case where I want to update a particular attribute of multiple items in a table. Is there an efficient way to do this in AppSync and DynamoDB? I cannot do a batchPutItem because I could be overwriting the item with expired attributes (another client updated an attribute). So the only option is to do UpdateItem one item at a time. I am thinking of having a loop in my iOS app that calls UpdateItem n times. Does this mean that there would be n network rounds? I want to be efficient with my design. Is there anyway I can do all the updates in one network round trip? Thank you.


Solution

  • Is there anyway I can do all the updates in one network round trip?

    I think you're on to a reasonable approach with this line of questioning.

    You could try setting up a mutation to be handled by a Lambda function data source. Have the Lambda function do your looping and report back with any conflicts. That way you can do it all in one network call.

    More about Lambda resolvers here: https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-lambda-resolvers.html