I am trying to make a custom resolver in VTL that will remove a certain string from a dynamodb list. I was trying to use $util.list.copyAndRemoveAll to remove the friend from the list. But I am not quite sure how to use it and the documentation isn't very clear to me and I don't even know if I am using the function correctly within VTL. https://docs.aws.amazon.com/appsync/latest/devguide/list-helpers-in-util-list.html
Thank you in advance.
GraphQL mutation
type Mutation {
removeFromIncomingFriendList(pk: String!, sk: String!, friend: String!): String!
}
#user_incoming_friend_requests is a list of usernames of users that have sent friend requests.
{
"version" : "2018-05-29",
"operation" : "UpdateItem",
"key" : {
"pk" : { "S" : "USER#USERNAME" },
"sk" : { "S" : "METADATA#USERNAME" },
},
"update": {
"expression" : "SET #user_incoming_friend_requests = :newList ADD version :plusOne",
"expressionNames": {
"#user_incoming_friend_requests" : "user_incoming_friend_requests",
},
"expressionValues" : {
":newList": $util.list.copyAndRemoveAll("#user_incoming_friend_requests", [${context.arguments.friend}])
":plusOne" : {"N":1}
}
}
}