Repository navigation
Send fragment definitions instead of inlining them - #145
Merged
Merged
Conversation
FieldCollector merges the fields of each operation per response path and concrete object type, resolving fragments itself. OperationGenerator walks that model without traversal state, adding __typename during emission. OperationStack and the duplicate check in ObjectLikeBuilder are gone. FoldFragments and AddTypename now only shape the document sent to the server. 🤖 Generated with Claude Code
The field collector resolves fragments itself, so FoldFragments only served the document sent to the server. Each operation now carries the fragments it uses, as written by the user, which also lifts the ban on fragment directives. Changes the document() strings of operations that use fragments. 🤖 Generated with Claude Code
🤖 Generated with Claude Code
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The advertised fragment-definition directive support lacks regression coverage.
Review effort: Balanced
Findings: 1
What changed in this PR
Updates code generation to send operations with their referenced fragment definitions instead of inlining fragment selections.
Changes:
- Removes fragment folding and collects transitively referenced fragments.
- Applies
__typenameprocessing to fragment definitions. - Updates generated operation documents and changelog.
| File | Description |
|---|---|
src/Codegen/OperationGenerator.php |
Collects and prints referenced fragments. |
src/Codegen/Generator.php |
Preserves fragments in the wire document. |
src/Codegen/FoldFragments.php |
Removes obsolete fragment inlining. |
src/Codegen/AddTypename.php |
Processes fragment selection sets. |
examples/simple/expected/Operations/NestedWithFragments.php |
Updates nested-fragment document. |
examples/simple/expected/Operations/ExplicitTypename.php |
Preserves the fragment definition. |
examples/simple/expected/Operations/ClientDirectiveFragmentSpreadQuery.php |
Preserves spread directives. |
examples/polymorphic/expected/Operations/UserOrPost.php |
Preserves the polymorphic fragment. |
CHANGELOG.md |
Records the wire-format change. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
FoldFragments and AddTypename modify nodes in place, so codegen read the folded document. 🤖 Generated with Claude Code
🤖 Generated with Claude Code
…nt-definitions # Conflicts: # src/Codegen/Generator.php
🤖 Generated with Claude Code
…itions # Conflicts: # src/Codegen/Generator.php # src/Codegen/OperationGenerator.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Stacked on #144.
Operations sent fragments folded into inline fragments, because codegen could not resolve spreads.
Codegen now resolves them itself, so each operation sends the fragments it uses as written.
The query text of operations with fragments changes
Persisted queries or allowlists keyed by query text need regenerating.
Generated classes stay identical: the 4 changed golden files differ only in
document().Directives on fragment definitions no longer fail codegen
FoldFragmentsrejected them because inlining would drop them.EndpointConfig::generateClasses() receives fragment definitions
It got the folded document before, so custom configs that read inline fragments there see spreads now.
🤖 Generated with Claude Code