How do you debug resolvers?
See original GitHub issue** Which Category is your question related to? ** API
** What AWS Services are you utilizing? ** AppSync
** Provide additional details e.g. code snippets **
Curious about how do you debug your resolvers. It is nice that resolvers are generated for us. However, there are cases (that directives @auth, @connection, etc haven’t covered) when we have to modify resolvers. Unfortunately, I don’t know how to debug resolver.
I tried to use CloudWatch to log (just as people print in Python/Java/…). E.g., in request template mapping, I add $ctx.identity hoping to print it to CloudWatch. No luck. Yes, $ctx.identity is not logged by CloudWatch 😦
$ctx.identity
{
"version": "2017-02-28",
"operation": "GetItem",
"key": {
"id": $util.dynamodb.toDynamoDBJson($ctx.args.id)
}
}
This will work with mock data, but mock data doesn’t help, in many cases. I also asked on AppSync forum, no luck.
According to AWS customer support, the AppSync team mentioned that they will consider the following as a feature request:
- Log
$ctx.identityobject in Cloudwatch - Ability to ‘print’/‘log’ in VTL
I am curious how do you debug? Or you simply do everything correctly? 🤣The question is also asked https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/14 and https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/15, but I don’t think it is answered.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:15
- Comments:7 (1 by maintainers)

Top Related StackOverflow Question
This is a real bummer.
This is a hack, but you can get
$ctx.identityto show up in the logs if you switch to a pipeline resolver and put the following line in the Before Mapping Template section:$util.toJson($ctx.identity)If you have logging enabled (with field resolver level set to All) then the value of this variable will appear in the very first Request Mapping log line as the value of
context.prev.result.If you’re not using a pipeline resolver you can always convert to one, do your debugging, then copy/paste your code into a new resolver once you’re done.