Repository navigation
Conversation
🤖 Generated with Claude Code
This was referenced Oct 3, 2026
Owner
Author
|
🤖 Superseded by #148, which also supports the directives on inline fragments and fragment spreads. |
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.
Part of #149
A field with
@skipor@includemay be missing from the response, which Sailor rejects today.This supports the directives on fields only, and fails code generation everywhere else.
Alternatives: #79 (full support), #148 (full support on the merged field model), #143 (reject the directives)
A field with the directive becomes nullable and may be absent
email @skip(if: $skipEmail)generatesstring|null, andmake()takes it as an optional argument.The converter is wrapped in
OmittableConverter, andObjectLike::fromGraphQL()skips a missing field only for that wrapper.NonNullConverterstays inside, so a present explicitnullon a non-null field still fails.Code generation fails for directives on inline fragments and fragment spreads
FoldFragmentsthrows before it inlines a spread, so the message names the spread rather than the inline fragment it would become:Sailor only supports @skip and @include on fields, found @skip on fragment spread ...TwoArgs.Sailor only supports @skip and @include on fields, found @include on inline fragment on Query.The workaround is to move the directive onto the fields.
Rule: a field with the directive must be the only selection at its response path
The response path is the chain of response names from the operation to the field, through fragments and regardless of type conditions.
With
a @skip(if: $x) { b } a { c }, the server returnsawith onlyc, sobwould be missing from a presenta.The same applies when an ancestor is selected twice, or a fragment selects the field again.
Codegen fails with
... found @skip on Foo.singleObject which is selected 2 times. Give the selections distinct aliases.The rule also rejects some sound queries, such as the same field under two different type conditions, or
a @skip(if: $x) a.Distinct aliases fix all of them.
Literal arguments get no special case
@skip(if: false)and@include(if: true)also make the field nullable, and also fail on fragments.This is looser than needed, but keeps the code free of argument evaluation.
The omission logic is about half the size of #79
git diff --stat origin/master...HEAD -- src: 7 files, 143 insertions, 10 deletions.#79: 6 files, 278 insertions, 34 deletions.
Operations that generated before may now fail codegen
ClientDirectiveFragmentSpreadQueryandClientDirectiveInlineFragmentQueryinexamples/simplenow fail, so this removes them.They already failed at runtime with
Missing fieldwhenever the server skipped the fragment.🤖 Generated with Claude Code