Search code examples
javascriptamazon-web-servicesfacebook-graph-apiaws-appsync

How can I change the status code of App sync AWS?


That's the error data returned from App Sync AWS: { "data": { "getContentById": null }, "errors": [ { "path": [ "getContentById" ], "data": null, "errorType": "Lambda:Handled", "errorInfo": null, "locations": [ { "line": 1, "column": 2, "sourceName": null } ], "message": "ID is not found" } ] } How can I change the 200 Status code from my lambda function? Screen shot from PostMan


Solution

  • Currently you cannot customize the error status code in AWS AppSync. The suggested approach is to use errorType in the error response. You can use $util.appendError or $util.error methods in your velocity mapping template to define the error type.