Skip to content

Formatted output, possibleTypes, type name escaping, document validation - #5

Merged
ifmelate merged 6 commits into
masterfrom
feature/v2.2-codegen-hygiene
Oct 17, 2026
Merged

ifmelate merged 6 commits into
masterfrom
feature/v2.2-codegen-hygiene

Conversation

@ifmelate

@ifmelate ifmelate commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Changes for 2.2.0.

Added

  • Generated files are formatted with dart_style for the language version of the package being built (from BuildStep.packageConfig), so dart format --set-exit-if-changed passes in user projects
  • types.dart exports possibleTypes (Map<String, Set<String>>) for GraphQLCache(possibleTypes: ...)
  • Operations are validated against the schema: unknown fields at any depth (BLD103, was root only), unknown or missing required arguments (BLD105), variable problems (BLD106), selection set and fragment type problems (BLD107). All problems are reported at once with path and line. validate_documents: false turns it off

Fixed

  • Schema types named like identifiers the generated code uses (Map, String, Object, Future, Set, JsonKey, object types Decimal/Long/Byte, ...) produced code that didn't compile. They now get a trailing underscore in Dart (type Map → class Map_); __typename dispatch and possibleTypes keep the GraphQL names
  • With strict_nullability, [CustomScalar!]! / [DateTime!]! / [Decimal!]! fields didn't compile because the list helpers returned nullable lists (found while adding the collision test)

Behavior change

  • A build now fails for operations the schema rejects. Documented in the CHANGELOG with the escape hatch

Dependencies

  • Minimum SDK raised to Dart 3.4 (Flutter 3.22): dart_style >=2.3.7 depends on analyzer 6.5+, which needs macros (SDK 3.4). Projects on older SDKs keep resolving 2.1.0. Verified locally on Dart 3.4.0 with the oldest resolvable versions (dart_style 2.3.7, build 2.4.1, build_test 2.2.2): all 144 tests pass. CI matrix moved from 3.2.0 to 3.4.0
  • build: ^2.4.0 (for packageConfig), dart_style: ">=2.3.7 <4.0.0" (first version with languageVersion; works with old and new build_runner), pub_semver

Tests

  • 144 tests (was 116). The compile test has a new collide variant: a schema full of colliding names, compiled, analyzed and run. The smoke client now uses GraphQLCache(possibleTypes: possibleTypes)

Files are formatted for the language version of the package being built,
so they pass `dart format --set-exit-if-changed` in user projects.
- types.dart exports `possibleTypes` for GraphQLCache(possibleTypes: ...)
- Schema types named like identifiers the generated code uses (Map, String,
  Object, Future, Set, JsonKey, Decimal, ...) get a trailing underscore in
  Dart; __typename dispatch and possibleTypes keep the GraphQL names
- Fix: non-null lists of custom scalars, DateTime, LocalDate and Decimal did
  not compile with strict_nullability (list helpers returned nullable lists)
- Compile test covers a schema full of colliding names
Unknown fields at any depth (BLD103), unknown or missing required arguments
(BLD105), undeclared, unused or wrongly typed variables (BLD106) and missing
or unexpected selection sets and invalid fragment types (BLD107) are reported
together, with path and line. `validate_documents: false` turns it off.
@ifmelate
ifmelate merged commit 0bfd1c3 into master Oct 17, 2026
2 checks passed
@ifmelate ifmelate mentioned this pull request Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant