title: Aws Appsync $util.error: data and errorInfo always null
body: <p>I am playing with AWS AppSync. I am trying to output some error details when the request fails using the <code>$util.error()</code> helper (<a href="https://docs.aws.amazon.com/appsync/latest/devguide/resolver-util-reference.html" rel="nofollow noreferrer">Documented here</a>) in my resolver's response mapping template. No matter what I do, I am not able to get AppSync to output the <code>data</code> and <code>errorInfo</code> fields in the <code>error</code> output.</p>
  
  <p>Here is the Lambda I have.</p>
  
  <pre><code>exports.handler = (event, context, callback) =&gt; {
  
    callback(null, {
      data: {
        name: "Test",
      },
      errorMessage: "Some error Message",
      errorType: "SomeErrorType",
      errors: {
        "foo": "bar",
        "bazz": "buzz",
      }
    })
  };
  </code></pre>
  
  <p>As you can see, it is pretty much straight forward. I just return an object with the <code>data</code>, <code>errors</code>, <code>errorMessage</code> and <code>errorType</code> properties.</p>
  
  <p>And here is my response mapping template</p>
  
  <pre><code>$utils.error($context.result.errorMessage, $context.result.errorType, $context.result.data, $context.result.errors)
  </code></pre>
  
  <p>Again, pretty much straight forward. I just throw an error directly using the fields coming from the Lambda.</p>
  
  <p>But when I execute the query, I get this:</p>
  
  <pre><code>{
    "data": {
      "myField": null
    },
    "errors": [
      {
        "path": [
          "myField"
        ],
        "data": null,
        "errorType": "SomeErrorType",
        "errorInfo": null,
        "locations": [
          {
            "line": 2,
            "column": 3,
            "sourceName": null
          }
        ],
        "message": "Some error Message"
      }
    ]
  }
  </code></pre>
  
  <p>As you can see, the <code>errorType</code> and <code>message</code> fields get populated correctly, but not the <code>errorInfo</code> and <code>data</code> ones. </p>
  
  <p>Am I missing something? Why isn't this working ?</p>
  
  <p>I also tried hardcoding the parameters of <code>$util.error</code> in the template. I got the same result...</p>