尝试禁用有关输入验证错误的显式消息。当我请求一个不存在的字段(即年龄)时,我得到:
{
"data": null,
"errors": [{
"path": null,
"locations": [
{
"line": 1,
"column": 129,
"sourceName": null
}
],
"message": "Validation error of type FieldUndefined: Field 'age' in type 'Patient' is undefined @ 'path/age'"
}]}
我想覆盖错误以显示自定义错误消息:
{
"data": null,
"errors": [
{
"message": "invalid fields"
}
]}
我的带有自定义 SystemError 的架构示例(不起作用):
type Patient {
id: Int!
firstName: String
lastName: String
}
type Query {
patient(id: Int!): Patient
errors: [SystemError]
}
type SystemError {
id: Int!
message: String
}
schema {
query: Query
}