Append item to list using AWS AppSync to DynamoDB


This might be a stupid question, but I really cannot find a way to do that.

So, I have DynamoDB tables and I have schema in AppSync api. In a table, for each row, there is a field which has a list as its value. So how can I append multiple items into this list without replacing the existing items? How should I write the resolver of that mutation?

Here is the screenshot of my table:

table pic

And you can see there are multiple programs in the list.

How can I just append two more programs.

Here is a new screenshot of my resolver:
screenshot of resolver
I want to add a existence check method in UpdateItem operation. But the current code does not work. The logic I want is that use the “contains” method to see whether the “toBeAddedProgramId” already exists. But the question is, how to extract the current program id list from User table and how to make the program id list a “list” type (since the contains method only take String set and String).

I hope this question makes sense. Thanks so much guys.



To append items to a list, you should use the DynamoDB UpdateItem operation.
Here is an example if you’re using DynamoDB directly

In AWS AppSync, you can use the DynamoDB data source and specify the DynamoDB UpdateItem operation in your request mapping template.

Your UpdateItem request template could look like the following (modify it to serve your needs):

We have a tutorial here that goes into more details if you are interested in learning more

Leave a Reply