我正在使用 webonyx/graphql-php 创建一些 graphql 查询,并且文档非常不完整,解释了如何在解析查询期间处理自定义错误。例如,如果用户应用程序发送查询以查找某些记录,我想返回一个自定义错误“未找到客户”,而不仅仅是这个丑陋的结构
[
'debugMessage' => 'Actual exception message',
'message' => 'Internal server error',
'category' => 'internal',
'locations' => [
['line' => 10, 'column' => 2]
],
'path' => [
'listField',
0,
'fieldWithException'
],
'trace' => [
/* Formatted original exception trace */
]
];
我读了很多次文档(https://webonyx.github.io/graphql-php/error-handling/),但不明白该怎么做。请问你能帮帮我吗?
谢谢!