'Access nested body property from HTTP resolver(AppSync)

I'm new to AWS AppSync and I am trying to access certain body property(from HTTP response) in my resolver's response mapping template. For example: I am able to present the response as is via $util.toJson($ctx.result.body), but when I try to get some of the nested body properties it fails.

For example, imagine the body looks like this:

{
  about:{
    "firstName":"Chuck",
    "lastName":"Norris"
  }
}

and $util.toJson($ctx.result.body.about) returns null. Any thoughts?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source