🐛

[Flutter] gql_build:data_builder on lib/graphql/user.graphql (cached):

2021/12/08に公開

エラー

build_runnerでコケた。
Ferry使っている部分のジェネレーターで失敗してる。

flutter pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 527ms

[INFO] Initializing inputs
[INFO] FlutterGen Loading ... pubspec.yaml
[INFO] Reading cached asset graph...
[INFO] Generated: /Users/hayashikengo/ghq/github.com/hayashikengo/kakeibo_mobile/lib/gen/assets.gen.dart
[INFO] FlutterGen finished.
[INFO] Reading cached asset graph completed, took 313ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 962ms

[INFO] Running build...
[INFO] 1.0s elapsed, 2/3 actions completed.
[INFO] 2.8s elapsed, 2/3 actions completed.
[INFO] 3.9s elapsed, 3/8 actions completed.
[INFO] 5.0s elapsed, 3/8 actions completed.
[INFO] 12.9s elapsed, 3/8 actions completed.
[INFO] Running build completed, took 13.5s

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

[SEVERE] built_value_generator:built_value on lib/graphql/mutations/user.req.gql.dart (cached):
Error in BuiltValueGenerator for abstract class GCreateUserReq implements Built<GCreateUserReq, dynamic>, OperationRequest<dynamic, GCreateUserVars>.
Please make the following changes to use BuiltValue:

1. Make field optimisticResponse 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/graphql/mutations/user.req.gql.dart (cached):
Error in BuiltValueGenerator for abstract class GUpdateUserReq implements Built<GUpdateUserReq, dynamic>, OperationRequest<dynamic, GUpdateUserVars>.
Please make the following changes to use BuiltValue:

1. Make field optimisticResponse 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/graphql/mutations/user.req.gql.dart (cached):
Error in BuiltValueGenerator for abstract class GDeleteUserReq implements Built<GDeleteUserReq, dynamic>, OperationRequest<dynamic, GDeleteUserVars>.
Please make the following changes to use BuiltValue:

1. Make field optimisticResponse 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/graphql/mutations/user.var.gql.dart (cached):
Error in BuiltValueGenerator for abstract class GCreateUserVars implements Built<GCreateUserVars, dynamic>.
Please make the following changes to use BuiltValue:

1. Make field createUser have non-dynamic type. If you are already specifying a type, please make sure the type is correctly imported.
[SEVERE] gql_build:data_builder on lib/graphql/mutations/user.graphql (cached):

Bad state: No element
[SEVERE] Failed after 13.6s
pub finished with exit code 1

解決策

lib/graphql/mutations/user.graphql で失敗してるよ。
「Type 正しくimportされてる?間違ってないかい?」って言われてる。

If you are already specifying a type, please make sure the type is correctly imported.
[SEVERE] gql_build:data_builder on lib/graphql/mutations/user.graphql (cached):

graphql/mutations/user.graphql
mutation CreateUser($createUser: CreateUser!) {
    # ↓ここタイポしてる
    creatUser(input: $createUser) {
        id
        name
        email
        iconUrl
        createdAt
        updatedAt
    }
}

creatUserがタイポしてた。
存在しないmutation名を指定していたことが原因だったので、直したら動いた。

graphql/mutations/user.graphql
mutation CreateUser($createUser: CreateUser!) {
    # ↓ここタイポしてる
    createUser(input: $createUser) {
        id
        name
        email
        iconUrl
        createdAt
        updatedAt
    }
}

Discussion