2

我有这个 GraphQL 查询:

query QuoteRequests($page: Int!) {
  getQuoteRequestsList(page: $page) {
    vehicle
    body
    licensePlate
    vin
    quality
    currency
    items
  }
}

它生成此示例结果:

{
    "data": {
        "getQuoteRequestsList": [
            {
                "vehicle": "1997 TOYOTA AVALON 4 DR ",
                "body": "Sedan",
                "licensePlate": "RHJ456",
                "vin": "XBGGDFYYREAXVJJJD",
                "quality": [
                    "GENUINO"
                ],
                "currency": "USD",
                "items": [
                    {
                        "uid": "74355f85-5312-9999-8acd-709ceccda00a",
                        "name": "Doble cero que es",
                        "description": "no me interesa",
                        "quantity": 11
                    },
                    {
                        "uid": "66db6fe0-1044-4d58-8454-5e51ab7a313f",
                        "name": "El arenero",
                        "description": "el duende verde",
                        "quantity": 2
                    }
                ]
            },
        ]
    }
}

项目数据是 JSON 类型当尝试使用Ferry包获取该数据时

client.request(GQuoteRequestsReq((b) => b..vars.page = 0)).listen((response) => print(response.data.toString()));

我得到一个空结果,但如果我将项目排除在查询之外,我会得到一个非空结果。如果我使用HTTP包运行该查询,我没有问题。

这是包的错误吗?还是我需要配置一些东西?

谢谢。

更新 1

这绝对是一个错误,因为如果我尝试在 Flutter 中进行热重载,我会在调试控制台中收到此错误:

Reloaded 1 of 1700 libraries in 860ms.
E/flutter ( 2286): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Deserializing '[__typename, Query, getQuoteRequestsList, [{__typename: GetQuoteRequestsRecor...' to 'GQuoteRequestsData' failed due to: Deserializing '[{__typename: GetQuoteRequestsRecord, uid: 0bf6709f-7ab7-464e-8ee3-6a94e46f05...' to 'BuiltList<GQuoteRequestsData_getQuoteRequestsList>' failed due to: Deserializing '[__typename, GetQuoteRequestsRecord, uid, 0bf6709f-7ab7-464e-8ee3-6a94e46f057...' to 'GQuoteRequestsData_getQuoteRequestsList' failed due to: Deserializing '[{uid: 16870250-5acb-4c23-a7e4-f4e23bbd23ad, name: Doble cero que es, descrip...' to 'GJSON' failed due to: type 'List<dynamic>' is not a subtype of type 'String?' in type cast
E/flutter ( 2286): #0      BuiltJsonSerializers._deserialize
package:built_value/src/built_json_serializers.dart:178
E/flutter ( 2286): #1      BuiltJsonSerializers.deserialize
package:built_value/src/built_json_serializers.dart:124

很明显它正在获取预期的结果,但它无法正确反序列化,然后它返回一个空结果。

有什么解决方法吗?

更新 2

我已经尝试过这个解决方案,但我遇到了同样的错误。

在我的情况下,我已经按照这些步骤,我已经

  • 安装built_value包,
  • 编辑build.yaml的文件,
  • 运行命令flutter packages pub run build_runner build
4

1 回答 1

1

在这个问题中可以找到答案。

于 2021-12-21T11:51:47.427 回答