5

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

  • https://stackoverflow.com/questions/31329495/is-there-a-way-to-change-the-http-status-codes-returned-by-amazon-api-gateway – ceejayoz Oct 10 '18 at 17:34

1 Answers1

2

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.

Karthik
  • 934
  • 9
  • 21
  • 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? – Jhonatan Jun 18 '20 at 23:29
  • 1
    Is this answer still the case? I'm not a fan – greenie-beans Jun 23 '20 at 16:14
  • @greenie-beans i am considering dropping aws appsync because of these silly design decisions – jpell Dec 27 '21 at 02:29
  • 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: https://sachee.medium.com/200-ok-error-handling-in-graphql-7ec869aec9bc – greenie-beans Jan 04 '22 at 15:23