0
votes

I'm working on a React Native application with AppSync, and following is my schema to the problem:

type JoineeDeletedConnection {
    items: [Joinee]
    nextToken: String
}
type Mutation {
    deleteJoinee(ids: [ID!]): [Joinee]
}

In 'request mapping template' to resolver to deleteJoinee, I have following (following the tutorial from https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-dynamodb-batch.html):

#set($ids = [])
#foreach($id in ${ctx.args.ids})
    #set($map = {})
    $util.qr($map.put("id", $util.dynamodb.toString($id)))
    $util.qr($ids.add($map))
#end

{
    "version" : "2018-05-29",
    "operation" : "BatchDeleteItem",
    "tables" : {
        "JoineesTable": $util.toJson($ids)
    }
}

..and in 'response mapping template' to the resolver,

$util.toJson($ctx.result.data.JoineesTable)

The problem is, when I ran the query, I got empty result and nothing deleted to database as well:

// calling the query
mutation DeleteJoinee {
  deleteJoinee(ids: ["xxxx", "xxxx"])
  {
      id
  }
}

// returns
{
  "data": {
    "deleteJoinee": [
      null
    ]
  }
}
1
can you enable the cloudwatch logs and post what you get back - Vasileios Lekakis
I think somehow I able to enable cloudwatch logs, and here are my output by the mutation query - socrates.io/#DADKwr4. One thing I want to let you note, that if I execute the query as a single delete by id resolver, that works good. - Santanu Karar
It looks like an access error - but as said, the deletion works fine when delete single by id. - Santanu Karar

1 Answers

1
votes

I finally able to solve this puzzle, thanks to the answer mentioned here to point me to some direction.

Although, I noticed that JoineesTable does have trusted entity/role to the IAM 'Roles' section, yet it wasn't working for some reason. Looking into this more, I noticed that the existing policy had following actions as default:

"Action": [
    "dynamodb:DeleteItem",
    "dynamodb:GetItem",
    "dynamodb:PutItem",
    "dynamodb:Query",
    "dynamodb:Scan",
    "dynamodb:UpdateItem"
]

Once I added following two more actions to the list, things have started working:

"dynamodb:BatchWriteItem",
"dynamodb:BatchGetItem"

Thanks to @Vasileios Lekakis and @Ionut Trestian on this appSync quest )