gql-dart / ferry

Stream-based strongly typed GraphQL client for Dart
https://ferrygraphql.com/
MIT License
593 stars 113 forks source link

Null check operator used on a null value and "Bad Element" #593

Closed simplenotezy closed 3 months ago

simplenotezy commented 3 months ago

I am trying to parse this:

all_shows.graphql

# import 'show_card_fragment.graphql'

query AllShows($countryCodes: [String!]!, $serviceNames: [String!]!, $page: Int!) {
  shows(countryCodes: $countryCodes, serviceNames: $serviceNames, page: $page) {
     ...ShowCard
  }
}

show_card_fragment.graphql

fragment NestedFragment on Show {
  title
  posterUrl
}

fragment ShowCard on Show {
  ...NestedFragment
}

But when running the build_runner I get this error:

❯ dart run build_runner build --delete-conflicting-outputs
Building package executable... (4.0s)
Built build_runner:build_runner.
[INFO] Generating build script completed, took 209ms
[INFO] Precompiling build script... completed, took 3.0s
[INFO] Building new asset graph completed, took 1.1s
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[INFO] Generating SDK summary completed, took 2.9s
[SEVERE] ferry_generator:graphql_builder on lib/features/show/data/graphql/show_card_fragment.graphql:

Null check operator used on a null value
package:gql_code_builder/src/operation/data.dart 152:8  buildSelectionSetDataClasses.<fn>
dart:core                                               Iterable.toList
package:gql_code_builder/src/operation/data.dart 169:5  buildSelectionSetDataClasses
package:gql_code_builder/src/operation/data.dart 58:8   buildFragmentDataClasses
package:gql_code_builder/data.dart 51:19                buildDataLibrary.<fn>
dart:core                                               Iterable.toList
package:gql_code_builder/data.dart 61:8                 buildDataLibrary
package:ferry_generator/graphql_builder.dart 104:22     GraphqlBuilder.build

[SEVERE] ferry_generator:graphql_builder on lib/features/show/data/graphql/all_shows.graphql:

Bad state: No element
dart:collection                                          ListBase.firstWhere
package:gql_code_builder/src/operation/data.dart 457:8   _getFieldTypeNode
package:gql_code_builder/src/operation/data.dart 153:24  buildSelectionSetDataClasses.<fn>
dart:core                                                Iterable.toList
package:gql_code_builder/src/operation/data.dart 169:5   buildSelectionSetDataClasses
package:gql_code_builder/src/operation/data.dart 24:10   buildOperationDataClasses
package:gql_code_builder/data.dart 36:17                 buildDataLibrary.<fn>
dart:core                                                Iterable.toList
package:gql_code_builder/data.dart 46:8                  buildDataLibrary
package:ferry_generator/graphql_builder.dart 104:22      GraphqlBuilder.build

[INFO] Running build completed, took 15.8s
[INFO] Caching finalized dependency graph completed, took 91ms
[SEVERE] Failed after 15.9s

What am I missing here?

simplenotezy commented 3 months ago

My build.yaml was referencing the wrong schema