I have an AppSync API connected to a DynamoDB table and both are deployed using a CF template, but when I make requests to a particular resolver, it always hangs and then fails with "Failed to fetch". I've verified with IAM Policy Simulator that the role connected to the API is sufficient to run the scan specified in the requestMappingTemplate:
{
"version": "2017-02-28",
"operation": "Scan",
"limit": 500
}
I've also verified with dummy data in the console that the below responseMappingTemplate works:
#set($uniqueStates = [])
#foreach($item in $ctx.result.items)
#set($found = false)
#foreach($state in $uniqueStates)
#if(!$found && $item.state == $state.name)
#set($found = true)
$util.qr($state.institutions.add({"name": "$item.name", "id": "$item.id"}))
#end
#end
#if(!$found)
$util.qr($uniqueStates.add({"name":"$item.state","institutions":[{"name": "$item.name", "id": "$item.id"}]}))
#end
#end
{
"states": $util.toJson($uniqueStates)
}
I also followed directions to setup a logging role and attach it to the API. It will successfully create logs for introspection queries accessible through cloudwatch and set the log-level to ERROR.
When I go to the AppSync console for my API, all the settings appear as they should, but when I execute a valid query (as validated by the handy tools in the query building console) from the console (or anywhere else), it hangs and responds "Failed to fetch". The logs section also shows nothing. I'm tearing my hair out trying to discern why. Thanks ahead of time for your help!
It turns out that my problem was that my returned data from the response mapping template didn't match the schema, so it silently failed and resulted in a timeout error. Easy enough fix, but difficult to diagnose. The debug process I went through was by creating a new AppSync API devoted to one sample endpoint and step-by step made it the same as everything I had for the endpoint that was failing.