ferry icon indicating copy to clipboard operation
ferry copied to clipboard

Build runner generation on Flutter 2.10.3 for schema.graphql failed!!

Open minhhoangtn opened this issue 3 years ago • 11 comments

I can not generate code from schema.graphql file because flutter pub run build_runner build --delete-conflicting-outputs failed.

build_runner result: `[INFO] Generating build script... [INFO] Generating build script completed, took 378ms

[INFO] Precompiling build script...... [WARNING] /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/gql_code_builder-0.2.0/lib/src/ast.dart:618:12: Error: A non-null value must be returned since th e return type 'Expression' doesn't allow null.

  • 'Expression' is from 'package:code_builder/src/specs/expression.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/code_builder-4.1.0/lib/src/specs /expression.dart'). Expression _directiveLocation(DirectiveLocation location) { ^ [INFO] Precompiling build script... completed, took 5.5s

[SEVERE] Failed to precompile build script .dart_tool/build/entrypoint/build.dart. This is likely caused by a misconfigured builder definition.

pub finished with exit code 78 `

build.yaml : `targets: $default: builders: gql_build|schema_builder: enabled: true gql_build|ast_builder: enabled: true gql_build|data_builder: enabled: true options: schema: untitled|lib/schema.graphql gql_build|var_builder: enabled: true options: schema: untitled|lib/schema.graphql gql_build|serializer_builder: enabled: true options: schema: untitled|lib/schema.graphql

  ferry_generator|req_builder:
    enabled: true
    options:
      schema: untitled|lib/schema.graphql`

pubspec.yaml: `dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.2 ferry: ^0.10.4 gql_http_link: ^0.4.0 gql_code_builder:

dev_dependencies: flutter_test: sdk: flutter build_runner: ^2.1.4 ferry_generator: ^0.4.4`

minhhoangtn avatar Apr 20 '22 07:04 minhhoangtn

Are you able to resolve it?

MubeenNaeem avatar Apr 26 '22 09:04 MubeenNaeem

This is only temporary solution.

  1. Switching Ferry to its dev verion in pubspec.yaml: ferry: ^0.10.5-dev.3
  2. Switching Ferry_generator in your dev_dependencies:

ferry_generator: git: url: https://github.com/axrs/ferry.git path: packages/ferry_generator

  1. My build.yaml with some Custome Serializer:

targets: $default: builders: ferry_generator|graphql_builder: generate_for: - lib/graphql/news/** enabled: true options: schema: flutter_base|lib/graphql/news/schema.graphql type_overrides: DateTime: name: DateTime Upload: name: MultipartFile import: 'package:http/http.dart' ferry_generator|serializer_builder: enabled: true options: schema: flutter_base|lib/graphql/news/schema.graphql custom_serializers: - import: 'package:flutter_base/graphql/serializers/date_serializer.dart' name: DateSerializer - import: 'package:flutter_base/graphql/serializers/upload_serializer.dart' name: UploadSerializer built_value_generator:built_value: generate_for: - lib/graphql/news/** source_gen:combining_builder: generate_for: - lib/graphql/news/**

minhhoangtn avatar Apr 26 '22 09:04 minhhoangtn

@minhhoangtn [WARNING] Configuring gql_build:schema_builder in target app:app but this is not a known Builder

Are you familiar of this error?

MubeenNaeem avatar Apr 26 '22 09:04 MubeenNaeem

@minhhoangtn

[WARNING] Configuring gql_build:schema_builder in target app:app but this is not a known Builder

Are you familiar of this error?

Maybe you are missing ferry_generator in your dev_dependencie This is mine Screenshot 2022-04-26 165735 s

minhhoangtn avatar Apr 26 '22 09:04 minhhoangtn

When using the ferry_generator fork, nothing gets generated, and everything that was there, gets deleted:

grafik
[WARNING] Configuring `gql_build:schema_builder` in target `my_app:my_app` but this is not a known Builder
[WARNING] Configuring `gql_build:ast_builder` in target `my_app:my_app` but this is not a known Builder
[WARNING] Configuring `gql_build:data_builder` in target `my_app:my_app` but this is not a known Builder
[WARNING] Configuring `gql_build:var_builder` in target `my_app:my_app` but this is not a known Builder
[WARNING] Configuring `gql_build:serializer_builder` in target `my_app:my_app` but this is not a known Builder
[WARNING] Configuring `ferry_generator:req_builder` in target `my_app:my_app` but this is not a known Builder

appinteractive avatar Apr 26 '22 21:04 appinteractive

So I can finaly confirm that the isue is gone with using all stable versions and pinning the versions:

ependency_overrides:
  analyzer: ^3.3.0
  gql: 0.13.0

At least as long I do NOT use --delete-conflicting-outputs

appinteractive avatar Apr 28 '22 13:04 appinteractive

I'm having the same issue. With the stable versions of ferry and ferry_generator, I'm getting

[WARNING] ../../../../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/gql_code_builder-0.2.0/lib/src/ast.dart:618:12: Error: A non-null value must be returned since the return type 'Expression' doesn't allow null.
 - 'Expression' is from 'package:code_builder/src/specs/expression.dart' ('../../../../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/code_builder-4.1.0/lib/src/specs/expression.dart').
Expression _directiveLocation(DirectiveLocation location) {
           ^
[INFO] Precompiling build script... completed, took 5.9s

[SEVERE] Failed to precompile build script .dart_tool/build/entrypoint/build.dart.
This is likely caused by a misconfigured builder definition.

After upgrading both packages to dev, I'm getting this:

[WARNING] Configuring `gql_build:schema_builder` in target `shsdk:shsdk` but this is not a known Builder
[WARNING] Configuring `gql_build:ast_builder` in target `shsdk:shsdk` but this is not a known Builder
[WARNING] Configuring `gql_build:data_builder` in target `shsdk:shsdk` but this is not a known Builder
[WARNING] Configuring `gql_build:var_builder` in target `shsdk:shsdk` but this is not a known Builder
[WARNING] Configuring `gql_build:serializer_builder` in target `shsdk:shsdk` but this is not a known Builder
[WARNING] Configuring `ferry_generator:req_builder` in target `shsdk:shsdk` but this is not a known Builder
[SEVERE] Nothing can be built, yet a build was requested.

It doesn't matter whether or not I use the --delete-conflicting-outputs flag.

sunderee avatar Jun 06 '22 08:06 sunderee

@sunderee did you add gql_build as a package?

appinteractive avatar Jun 06 '22 15:06 appinteractive

@appinteractive correct, I did. To no avail. I've dropped working with the library and I've instead reverted to manually deserializing all models.

sunderee avatar Jun 09 '22 12:06 sunderee

@appinteractive correct, I did. To no avail. I've dropped working with the library and I've instead reverted to manually deserializing all models.

@appinteractive @sunderee if you are working with dev version check this

chungonion avatar Jul 06 '22 15:07 chungonion

Thanks @chungonion, I did the switch already to the graphql package.

appinteractive avatar Jul 06 '22 17:07 appinteractive

Fixed with the latest stable

knaeckeKami avatar Aug 23 '22 21:08 knaeckeKami