我在我的颤振应用程序中使用包graphql_flutter进行 GraphQL 操作。查询和突变进展顺利,但我无法按照他们文档中提到的方式检索错误。每次我收到一般错误消息时,
ClientException: Failed to connect to http://127.0.0.1:3006/graphql:
我做得到,
print(result.exception.toString());
我的突变看起来像,
final MutationOptions mutationOptions = MutationOptions(
documentNode: gql(mutationString),
variables: vars
);
final QueryResult result = await _instance._client.mutate(mutationOptions);
if (result.hasException) {
// none of the following prints the expected error.
print(result.exception.clientException.message);
print(result.exception.graphqlErrors);
print(result.exception.toString());
}
print(result.data);
return result.data;
而在阿波罗客户端,我的错误是:
{
"errors": [
{
"message": "Invalid Phone number provided",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"otp"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
....
但我什么都没有。
注意:成功响应如期而至。我想知道如何获取 graphql 错误。