Ferry generator does not generate .data.gql file when using inline fragment inside fragment

527 views Asked by At

I am trying to create a queryC that returns an interface type. But after I run the ferry generator, the file query.my_query.data.gql.dart is not generated.

These are the files:

  • query.my_query.graphql
  • fragment.my_fragment.graphql
  • schema.graphql

These are the outputs after running:

  • flutter pub run build_runner build --delete-conflicting-outputs
  • flutter pub run build_runner build --delete-conflicting-outputs -v

query.my_query.graphql

import '../fragment/fragment.my_fragment.graphql'
query MyQuery {
  queryA {
    ...MyFragment
  }
  queryB {
    ...MyFragment
  }
  queryC {
    ...MyFragment
  }
}

fragment.my_fragment.graphql

fragment MyFragment on MyInterface {
  fieldA
  fieldB
  ... on TypeA {
    fieldC
  }
  ... on TypeB {
    fieldD
  }
}

schema.graphql

interface MyInterface {
  fieldA: String!
  fieldB: String!
}
type TypeA implements MyInterface {
  fieldA: String!
  fieldB: String!
  fieldC: String!
}
type TypeB implements MyInterface {
  fieldA: String!
  fieldB: String!
  fieldD: String!
}

type Query {
  queryA: [TypeA!]!
  queryB: [TypeB!]!
  queryC: [MyInterface!]!
}

Output

> flutter pub run build_runner build --delete-conflicting-outputs
...
[SEVERE] built_value_generator:built_value on lib/graphql/query/query.my_query.req.gql.dart (cached):
Error in BuiltValueGenerator for abstract class GMyQueryReq implements Built<GMyQueryReq, dynamic>, OperationRequest<dynamic, GMyQueryVars>.
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] gql_build:data_builder on lib/graphql/query/query.my_query.graphql (cached):

Stack Overflow
[SEVERE] Failed after 82ms
pub finished with exit code 1
> flutter pub run build_runner build --delete-conflicting-outputs -v
...
[INFO] Build:Running build completed, took 9m 23s

[INFO] Build:Caching finalized dependency graph...
[INFO] Heartbeat:9m 27s elapsed, 9040/9040 actions completed.
[INFO] Build:Caching finalized dependency graph completed, took 3.8s

[SEVERE] Build:
Failed after 9m 27s
[+579761 ms] "flutter run" took 580,600ms.
[  +16 ms] pub finished with exit code 1
[   +2 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:416:7)
           <asynchronous suspension>
           #2      PackagesForwardCommand.runCommand (package:flutter_tools/src/commands/packages.dart:251:5)
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1161:27)
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #5      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
           <asynchronous suspension>
           #6      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
           <asynchronous suspension>
           #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #8      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
           <asynchronous suspension>
           #9      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #11     main (package:flutter_tools/executable.dart:94:3)
           <asynchronous suspension>
           
           
[  +66 ms] ensureAnalyticsSent: 62ms
[   +2 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 1
0

There are 0 answers