AppSync request mapping template errors not logged in CloudWatch

0

I have a simple resolver that has a simple Lambda function as a data source. This function always throws an error (to test out logging). The resolver has request mapping template enabled and it is configured as follows:

$util.error("request mapping error 1")

The API has logging configured to be as verbose as possible yet I cannot see this request mapping error 1 from my CloudWatch logs in RequestMapping log type:

{
    "logType": "RequestMapping",
    "path": [
        "singlePost"
    ],
    "fieldName": "singlePost",
    "resolverArn": "xxx",
    "requestId": "bab942c6-9ae7-4771-ba45-7911afd262ac",
    "context": {
        "arguments": {
            "id": "123"
        },
        "stash": {},
        "outErrors": []
    },
    "fieldInError": false,
    "errors": [],
    "parentType": "Query",
    "graphQLAPIId": "xxx"
}

The error is not completely lost because I can see this error in the query response:

{
  "data": {
    "singlePost": null
  },
  "errors": [
    {
      "path": [
        "singlePost"
      ],
      "data": null,
      "errorType": null,
      "errorInfo": null,
      "locations": [
        {
          "line": 2,
          "column": 3,
          "sourceName": null
        }
      ],
      "message": "request mapping error 1"
    }
  ]
}

When I add $util.appendError("append request mapping error 1") to the request mapping template so it looks like this:

$util.appendError("append request mapping error 1")
$util.error("request mapping error 1")

Then the appended error appears in the RequestMapping log type but the errors array is still empty:

{
    "logType": "RequestMapping",
    "path": [
        "singlePost"
    ],
    "fieldName": "singlePost",
    "resolverArn": "xxx",
    "requestId": "f8eecff9-b211-44b7-8753-6cc6e269c938",
    "context": {
        "arguments": {
            "id": "123"
        },
        "stash": {},
        "outErrors": [
            {
                "message": "append request mapping error 1"
            }
        ]
    },
    "fieldInError": false,
    "errors": [],
    "parentType": "Query",
    "graphQLAPIId": "xxx"
}

When I do the same thing with response mapping template then everything works as expected (errors array contains $util.error(message) and outErrors array contains $util.appendError(message) messages.

  1. Is this working as expected so the $util.error(message) will never show up in CloudWatch logs?
  2. Under what conditions will errors array in RequestMapping log type be populated?
  3. Bonus question: can the errors array contain more than 1 item for either RequestMapping or ResponseMapping log types?
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions