Add fragment-arguments#6882
Conversation
✅ Docs preview readyThe preview is ready to be viewed. View the preview File Changes 0 new, 2 changed, 0 removedBuild ID: 05d00e2f8255adb76aa46e40 URL: https://www.apollographql.com/docs/deploy-preview/05d00e2f8255adb76aa46e40 ✅ AI Style Review — No Changes DetectedNo MDX files were changed in this pull request. Review Log: View detailed log
|
BoD
left a comment
There was a problem hiding this comment.
Nice!!! 🎉
Love how this doesn't impact codegen.
Hmm I'm not following, do you have an example? |
…pollo/ast/internal/ExecutableValidationScope.kt Co-authored-by: Benoit 'BoD' Lubek <BoD@JRAF.org>
There is this text in the spec PR: This makes sense because this is not valid: fragment queryDetails($arg: Int!) on Query {
foo(arg: $arg)
}
{
...queryDetails(arg: 0)
...queryDetails(arg: 1)
}But we need to validate against non spreads as well: {
...queryDetails(arg: 0)
...queryDetails(arg: 1)
foo(arg: 2)
}So what I'm doing is I remove the variables before validation: {
foo(arg: 0)
foo(arg: 1)
foo(arg: 2)
}And I just run the field merging algorithm. There's no part that tries to check fragments specifically. In other terms, the message will always be I think that's OK. In a world where fragment definitions can only use the fragment-defined variables, this would simplify the validation. But since we can't really do this, might as well run our good old validation. |
|
Ah I see, thanks! So adding this validation would fail earlier with a more specific message. Makes sense an agree it's fine as-is 👍 |
This is based on graphql/graphql-spec#1081
Open questions:
FRAGMENT_VARIABLE_DEFINITION)? This PR doesn't.No answer is needed at this point. The feature is behind a feature flag in the parser.
Note: once a document is successfully parsed, there's no feature flag anymore, everything else supports fragment arguments experimentally.