0

我正在尝试从轮渡文档中描述的 schema.graphql 文件生成飞镖类型。

https://ferrygraphql.com/docs/codegen

构建 graphql 代码时出现此错误

 flutter pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 543ms

[INFO] Precompiling build script......
[INFO] Precompiling build script... completed, took 7.6s

[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 890ms

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms

[INFO] Running build...
[INFO] Generating SDK summary...
[INFO] 4.5s elapsed, 4/5 actions completed.
[INFO] Generating SDK summary completed, took 3.5s

[WARNING] gql_build:serializer_builder on lib/$lib$:
Your current `analyzer` version may not fully support your current SDK version.

Analyzer language version: 2.14.0
SDK language version: 2.16.0

Please update to the latest `analyzer` version (3.3.1) by running
`flutter packages upgrade`.

If you are not getting the latest version by running the above command, you
can try adding a constraint like the following to your pubspec to start
diagnosing why you can't get the latest version:

dev_dependencies:
  analyzer: ^3.3.1

[INFO] 6.0s elapsed, 4/5 actions completed.
[INFO] 7.1s elapsed, 5/9 actions completed.
[INFO] 8.1s elapsed, 5/9 actions completed.
[INFO] 9.3s elapsed, 5/9 actions completed.
[INFO] 16.4s elapsed, 5/9 actions completed.
[INFO] 18.3s elapsed, 5/9 actions completed.
[SEVERE] built_value_generator:built_value on lib/schema.schema.gql.dart:
Error in BuiltValueGenerator for /ferry_codegen_test/lib/schema.schema.gql.dart.
Please make the following changes to use built_value serialization:

1. Declare GENUM_AQUATIC_ACTIVETYPE.serializer as: static Serializer<GENUM_AQUATIC_ACTIVETYPE> get serializer => _$gENUMAQUATICACTIVETYPESerializer; got static Serializer<GENUM_AQUATIC_ACTIVETYPE> get serializer => _$genumAquaticActivetypeSerializer;
2. Declare GENUM_AQUATIC_BREEDINGLEVEL.serializer as: static Serializer<GENUM_AQUATIC_BREEDINGLEVEL> get serializer => _$gENUMAQUATICBREEDINGLEVELSerializer; got static Serializer<GENUM_AQUATIC_BREEDINGLEVEL> get serializer => _$genumAquaticBreedinglevelSerializer;
3. Declare GENUM_AQUATIC_CARELEVEL.serializer as: static Serializer<GENUM_AQUATIC_CARELEVEL> get serializer => _$gENUMAQUATICCARELEVELSerializer; got static Serializer<GENUM_AQUATIC_CARELEVEL> get serializer => _$genumAquaticCarelevelSerializer;
4. Declare GENUM_AQUATIC_DIET.serializer as: static Serializer<GENUM_AQUATIC_DIET> get serializer => _$gENUMAQUATICDIETSerializer; got static Serializer<GENUM_AQUATIC_DIET> get serializer => _$genumAquaticDietSerializer;
5. Declare GENUM_AQUATIC_SCHOOLING.serializer as: static Serializer<GENUM_AQUATIC_SCHOOLING> get serializer => _$gENUMAQUATICSCHOOLINGSerializer; got static Serializer<GENUM_AQUATIC_SCHOOLING> get serializer => _$genumAquaticSchoolingSerializer;
6. Declare GENUM_AQUATIC_SWIMLEVEL.serializer as: static Serializer<GENUM_AQUATIC_SWIMLEVEL> get serializer => _$gENUMAQUATICSWIMLEVELSerializer; got static Serializer<GENUM_AQUATIC_SWIMLEVEL> get serializer => _$genumAquaticSwimlevelSerializer;
7. Declare GENUM_AQUATIC_TEMPERAMENT.serializer as: static Serializer<GENUM_AQUATIC_TEMPERAMENT> get serializer => _$gENUMAQUATICTEMPERAMENTSerializer; got static Serializer<GENUM_AQUATIC_TEMPERAMENT> get serializer => _$genumAquaticTemperamentSerializer;
8. Declare GENUM_AQUATIC_TEMPUNIT.serializer as: static Serializer<GENUM_AQUATIC_TEMPUNIT> get serializer => _$gENUMAQUATICTEMPUNITSerializer; got static Serializer<GENUM_AQUATIC_TEMPUNIT> get serializer => _$genumAquaticTempunitSerializer;
9. Declare GENUM_AQUATIC_TYPE.serializer as: static Serializer<GENUM_AQUATIC_TYPE> get serializer => _$gENUMAQUATICTYPESerializer; got static Serializer<GENUM_AQUATIC_TYPE> get serializer => _$genumAquaticTypeSerializer;
10. Declare GENUM_BIT_TYPE.serializer as: static Serializer<GENUM_BIT_TYPE> get serializer => _$gENUMBITTYPESerializer; got static Serializer<GENUM_BIT_TYPE> get serializer => _$genumBitTypeSerializer;
11. Declare GENUM_COMPONENTMEDIAMEDIAUPLOAD_MEDIATYPE.serializer as: static Serializer<GENUM_COMPONENTMEDIAMEDIAUPLOAD_MEDIATYPE> get serializer => _$gENUMCOMPONENTMEDIAMEDIAUPLOADMEDIATYPESerializer; got static Serializer<GENUM_COMPONENTMEDIAMEDIAUPLOAD_MEDIATYPE> get serializer => _$genumComponentmediamediauploadMediatypeSerializer;
12. Declare GENUM_COMPONENTMEDIAMEDIAUPLOAD_STATUS.serializer as: static Serializer<GENUM_COMPONENTMEDIAMEDIAUPLOAD_STATUS> get serializer => _$gENUMCOMPONENTMEDIAMEDIAUPLOADSTATUSSerializer; got static Serializer<GENUM_COMPONENTMEDIAMEDIAUPLOAD_STATUS> get serializer => _$genumComponentmediamediauploadStatusSerializer;
13. Declare GENUM_CONTRIBUTE_TYPE.serializer as: static Serializer<GENUM_CONTRIBUTE_TYPE> get serializer => _$gENUMCONTRIBUTETYPESerializer; got static Serializer<GENUM_CONTRIBUTE_TYPE> get serializer => _$genumContributeTypeSerializer;
14. Declare GENUM_FUNFACT_CATEGORY.serializer as: static Serializer<GENUM_FUNFACT_CATEGORY> get serializer => _$gENUMFUNFACTCATEGORYSerializer; got static Serializer<GENUM_FUNFACT_CATEGORY> get serializer => _$genumFunfactCategorySerializer;
15. Declare GENUM_FUNFACT_STATUS.serializer as: static Serializer<GENUM_FUNFACT_STATUS> get serializer => _$gENUMFUNFACTSTATUSSerializer; got static Serializer<GENUM_FUNFACT_STATUS> get serializer => _$genumFunfactStatusSerializer;
16. Declare GENUM_PRODUCT_CATEGORY.serializer as: static Serializer<GENUM_PRODUCT_CATEGORY> get serializer => _$gENUMPRODUCTCATEGORYSerializer; got static Serializer<GENUM_PRODUCT_CATEGORY> get serializer => _$genumProductCategorySerializer;
17. Declare GENUM_PRODUCT_STATUS.serializer as: static Serializer<GENUM_PRODUCT_STATUS> get serializer => _$gENUMPRODUCTSTATUSSerializer; got static Serializer<GENUM_PRODUCT_STATUS> get serializer => _$genumProductStatusSerializer;
[INFO] 21.9s elapsed, 5/9 actions completed.
[WARNING] No actions completed for 15.9s, waiting on:
  - built_value_generator:built_value on lib/main.dart
  - built_value_generator:built_value on test/widget_test.dart
  - built_value_generator:built_value on lib/schema.schema.gql.dart
  - built_value_generator:built_value on lib/serializers.gql.dart

[INFO] 22.9s elapsed, 9/10 actions completed.
[INFO] Running build completed, took 23.0s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 33ms

[SEVERE] Failed after 23.0s
pub finished with exit code 1

我认为渡轮生成器与 graphql ENUM 类型有问题

谁能帮我解决这个问题?

谢谢

重现 repo https://github.com/aquadesk/ferry_codegen_test

发布规范.yaml

name: ferry_codegen_test
description: A new Flutter project.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev


version: 1.0.0+1

environment:
  sdk: ">=2.16.1 <3.0.0"

dependencies:
  flutter:
    sdk: flutter


  cupertino_icons: ^1.0.2
  ferry: ^0.10.4

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^1.0.0
  ferry_generator: ^0.4.4
  build_runner: ^2.1.7

flutter:

  uses-material-design: true

我认为schema.graphql文件太大,无法在此处发布。所以我会放一部分,这似乎是一个问题。


enum ENUM_AQUATIC_TEMPUNIT {
  F
  C
}
enum ENUM_AQUATIC_TYPE {
  fish
  frog
}
enum ENUM_BIT_TYPE {
  youtube
  instagram
  blog
  site
  commerce
  facebook
}


4

1 回答 1

0

我在这里找到了修复

https://github.com/gql-dart/gql/pull/225

在您的本地拉下这个 repo并签出这个更改 gql的提交 14e8d3602ebb93f14a2285247c80a9b70b1eb71bhttps://github.com/gql-dart/gql/commit/14e8d3602ebb93f14a2285247c80a9b70b1eb71b

并将其放在 pubspec.yaml 的末尾


dependency_overrides:
  gql_code_builder:
    path: ../../../gql/codegen/gql_code_builder

于 2022-03-02T15:58:21.580 回答