【发布时间】:2021-09-04 10:42:55
【问题描述】:
我在使用 Flutter Ferry graphql 包中的自定义序列化程序时遇到了一点问题:
我完全使用了渡轮文档中的示例: https://ferrygraphql.com/docs/custom-scalars/#create-a-custom-serializer
但我在运行 builder_runner 时总是收到以下消息:
[SEVERE] built_value_generator:built_value on lib/schema.schema.gql.dart:
Error in BuiltValueGenerator for abstract class GDailyForecastInput implements Built<GDailyForecastInput, dynamic>.
Please make the following changes to use BuiltValue:
1. Make field dateStart have non-dynamic type. If you are already specifying a type, please make sure the type is correctly imported.
2. Make field dateEnd have non-dynamic type. If you are already specifying a type, please make sure the type is correctly imported.
[SEVERE] built_value_generator:built_value on lib/schema.schema.gql.dart:
Error in BuiltValueGenerator for abstract class GHourlyForecastInput implements Built<GHourlyForecastInput, dynamic>.
Please make the following changes to use BuiltValue:
1. Make field dateStart have non-dynamic type. If you are already specifying a type, please make sure the type is correctly imported.
2. Make field dateEnd have non-dynamic type. If you are already specifying a type, please make sure the type is correctly imported.
dateStart 和 dateEnd 是 Date 类型的查询输入值 这是我的类型覆盖: 类型覆盖: 日期: 名称日期 有人为什么会发生此错误吗? 实在想不通是什么问题
日期在我的 schema.graphql 文件中定义为标量:
"""A date string with format `Y-m-d`, e.g. `2011-05-23`."""
scalar Date
这是我的 build.yaml 文件:
targets:
$default:
builders:
gql_build|schema_builder:
enabled: true
options:
type_overrides:
Date:
name: Date
gql_build|ast_builder:
enabled: true
options:
type_overrides:
Date:
name: Date
gql_build|data_builder:
enabled: true
options:
type_overrides:
Date:
name: Date
schema: appdemo|lib/schema.graphql
gql_build|var_builder:
enabled: true
options:
type_overrides:
Date:
name: Date
schema: appdemo|lib/schema.graphql
gql_build|serializer_builder:
enabled: true
options:
schema: appdemo|lib/schema.graphql
custom_serializers:
- import: './serializers/date_serializer.dart'
name: DateSerializer
ferry_generator|req_builder:
enabled: true
options:
type_overrides:
Date:
name: Date
schema: appdemo|lib/schema.graphql
我已经尝试过调试。如果我将我的标量重命名为 DateTime 一切正常。
(我的schema.graphql 文件中还有一个标量DateTime。)
只有当我使用名称 Date 时才会收到此错误。
我错过了什么吗?
我是否需要在文档中的代码之外创建一个 dart Date 类并链接它左右?
【问题讨论】:
标签: flutter dart built-value