Repository navigation
validator: reject duplicate argument definitions - #491
Merged
StevenACoffman merged 2 commits intoOct 8, 2026
Merged
StevenACoffman merged 2 commits into
StevenACoffman merged 2 commits into
Conversation
LoadSchema accepted a field or directive definition that declared the same argument twice, e.g. `field(id: ID, id: String)`. Lookups by name only ever see the first one, so the second declaration was silently ignored. Add the UniqueArgumentDefinitionNames check from graphql-js for field arguments on object/interface types and for directive definitions, reporting the second occurrence as "Argument Query.field(id:) can only be defined once." or "Argument @dir(id:) can only be defined once." Move the rule from the gaps list to the covered list in WIP.md.
There was a problem hiding this comment.
🟢 Approval recommended
The validation is correctly integrated, documented, and comprehensively tested across supported argument-definition contexts.
0 open findings
What changed in this PR
Adds schema validation rejecting duplicate argument definitions for fields and directives.
Changes:
- Validates argument-name uniqueness and reports the duplicate location.
- Adds positive and negative object, interface, and directive tests.
- Updates validation-gap documentation.
| File | Description |
|---|---|
WIP.md |
Marks argument-definition uniqueness as covered. |
validator/schema.go |
Adds duplicate argument-name validation. |
validator/schema_test.yml |
Adds regression and positive test cases. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The owner label for the duplicate-argument error was concatenated on every field and directive definition, adding ~95 allocs to BenchmarkLoadSchema. Return the duplicate instead and format the error only when one is found.
Collaborator
|
Hey, this is great! I really appreciated this improvement. Looking forward to the next one. I made a little performance tweak to your code. |
This was referenced Oct 8, 2026
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.
LoadSchemaaccepted a field or directive definition that declares the same argument twice, e.g.field(id: ID, id: String). Lookups by name only ever see the first one, so the second declaration was silently dropped.This adds graphql-js' UniqueArgumentDefinitionNames check for field arguments and directive definitions. It reports the second occurrence as
Argument Query.field(id:) can only be defined once.(orArgument @dir(id:) ...), the graphql-js message without the quotes, like the other schema errors here. It's listed as an unintentional gap in WIP.md, which I've updated.I have: