I've been following the tutorial for batch operations: https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-dynamodb-batch.html#multi-table-batch
When I tried to do a multi-table batch, I get a null response even though the objects are successfully submitted to dynamodb.
This is my mutation:
mutation sendReadings {
recordReadings(
tempReadings: [
{sensorId: 1, value: 85.5, timestamp: "2018-02-01T17:21:05.000+08:00"},
{sensorId: 2, value: 85.7, timestamp: "2018-02-01T17:21:06.000+08:00"},
{sensorId: 3, value: 85.8, timestamp: "2018-02-01T17:21:07.000+08:00"},
{sensorId: 4, value: 84.2, timestamp: "2018-02-01T17:21:08.000+08:00"},
{sensorId: 5, value: 81.5, timestamp: "2018-02-01T17:21:09.000+08:00"}
]
locReadings: [
{sensorId: 1, lat: 47.615063, long: -122.333551, timestamp: "2018-02-01T17:21:05.000+08:00"},
{sensorId: 2, lat: 47.615163, long: -122.333552, timestamp: "2018-02-01T17:21:06.000+08:00"}
{sensorId: 3, lat: 47.615263, long: -122.333553, timestamp: "2018-02-01T17:21:07.000+08:00"}
{sensorId: 4, lat: 47.615363, long: -122.333554, timestamp: "2018-02-01T17:21:08.000+08:00"}
{sensorId: 5, lat: 47.615463, long: -122.333555, timestamp: "2018-02-01T17:21:09.000+08:00"}
]) {
locationReadings {
sensorId
timestamp
lat
long
}
temperatureReadings {
sensorId
timestamp
value
}
}
}
The problem is that the response returns null:
{ "data": { "recordReadings": { "locationReadings": null, "temperatureReadings": null } } }
Request Mapping Template:
## Convert tempReadings arguments to DynamoDB objects #set($tempReadings = []) #foreach($reading in ${ctx.args.tempReadings}) $util.qr($tempReadings.add($util.dynamodb.toMapValues($reading))) #end ## Convert locReadings arguments to DynamoDB objects #set($locReadings = []) #foreach($reading in ${ctx.args.locReadings}) $util.qr($locReadings.add($util.dynamodb.toMapValues($reading))) #end { "version" : "2018-05-29", "operation" : "BatchPutItem", "tables" : { "LocationReadingTable": $utils.toJson($locReadings), "TemperatureReadingTable": $utils.toJson($tempReadings) } }
Response Mapping Template:
## If there was an error with the invocation ## there might have been partial results #if($ctx.error) ## Append a GraphQL error for that field in the GraphQL response $utils.appendError($ctx.error.message, $ctx.error.message) #end ## Also returns data for the field in the GraphQL response $utils.toJson($context.result.data)
The code is pretty much identical to the tutorial. I checked the logs and the response is being sent but it's not being captured so either my code is off or there is a bug on AWS's side. Can anyone reproduce this or is able to get a response when doing a multi-table BatchPutItem?