question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:

  1. Log $ctx.identity object in Cloudwatch
  2. 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:closed
  • Created 5 years ago
  • Reactions:15
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
sebastienficommented, Jan 10, 2020

This is a real bummer.

1reaction
sopranolinistcommented, May 15, 2020

This is a hack, but you can get $ctx.identity to 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test and debug resolvers (VTL) - AWS AppSync
Testing resolvers · Sign in to the AWS Management Console and open the AppSync console . · If you haven't done so already,...
Read more >
Debugging/logging of resolvers and functions - Prisma 1
Add this to your package. · type in your console (in the project) · In Webstorm click on “Edit Configurations” on the run/Debug...
Read more >
Add Analytics to your GraphQL API Server and Debug ... - Moesif
How to build a GraphQL API with Apollo and add analytics for debugging, and includes tips for VsCode as well.
Read more >
Debugging a single request - Knot Resolver - Read the Docs
Using query policies​​ DEBUG_CACHE_MISS or policy. DEBUG_IF can be used to enable debug-level logging for selected subdomains or queries matching specific ...
Read more >
How to monitor and debug AppSync APIs - Lumigo
This post explores how you can use CloudWatch, X-Ray and Lumigo to help you monitor your AWS AppSync APIs and debug problems.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found