Skip to content

prune_types: types.dart with only what the operations use - #16

Merged
ifmelate merged 3 commits into
masterfrom
feat/prune-types
Oct 25, 2026
Merged

ifmelate merged 3 commits into
masterfrom
feat/prune-types

Conversation

@ifmelate

Copy link
Copy Markdown
Owner

prune_types: true declares in types.dart only the enums, input types, custom scalars and possibleTypes entries that the operations and fragments of document_paths use.

  • Collected from all documents: enums and scalars of selected fields (fragments included), variable types with every input/enum/scalar their fields reach, interfaces and unions that are selected or used as a type condition.
  • Off by default: code using a type no operation selects would stop compiling. Operation result types only; warns with result_types: schema or types_import.
  • GitLab's public schema (4,580 types) with the two queries of tool/live_check/gitlab: 134,016 lines -> 421, live check passes.
  • GraphQLCodeGenerator.usedTypes(schema, documents) and generateTypesFile(schema, only: ...) for use outside the builder.

Tests: test/prune_types_test.dart (collection, generation, config, builder across documents), test/prune_types_compile_test.dart (compiles and runs pruned code, strict and legacy). Fast 364, compile 6.

@ifmelate
ifmelate merged commit feca718 into master Oct 25, 2026
2 checks passed
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