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
1 Answer
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.
4 Comments
Jhonatan
do you know if there are plans to implement this feature? Do you know if there is a roadmap to see how likely is some feature to be implemented, or even to propose one?
greenie-beans
Is this answer still the case? I'm not a fan
jpell
@greenie-beans i am considering dropping aws appsync because of these silly design decisions
greenie-beans
i'm pretty sure that graphql sends 200 responses for everything by default. we ended up creating some custom errors based on the parent answer, and then the client parsed out any errors based on the
errors key. this blog post has some background on graphql and errors: sachee.medium.com/200-ok-error-handling-in-graphql-7ec869aec9bc