Creates Koa middleware to handle errors. Use this before other middleware to catch all errors for a correctly formatted GraphQL response.
Special Koa middleware error properties can be used to determine how the error appears in the response payload errors array and the response HTTP status code.
A GraphQL resolver error may have these special properties for the errorHandler Koa middleware to use to determine how the error appears in the response payload errors array.
Type: object
Property
Type
Description
message
string
Error message. If the error expose property isn’t true, the message is replaced with Internal Server Error in the response payload errors array.
extensions
Record<string, any>?
A map of custom error data that is exposed to the client in the response payload errors array, regardless of the error expose or status properties.
expose
boolean?
Should the original error message be exposed to the client.
A Koa middleware error may have these special properties for the errorHandler Koa middleware to use to determine how the error appears in the response payload errors array and the response HTTP status code.
Type: object
Property
Type
Description
message
string
Error message. If the error status property >= 500 or the error expose property isn’t true, the message is replaced with Internal Server Error in the response payload errors array.
extensions
Record<string, any>?
A map of custom error data that is exposed to the client in the response payload errors array, regardless of the error expose or status properties.
status
number?
Determines the response HTTP status code.
expose
boolean?
Should the original error message be exposed to the client.
请发表评论