-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate: Unique variable names #296
Conversation
Looks good to me; I might change the field name to a real field in the sample schema to make it more clear that the valid queries are truly valid (and that the invalid queries are only invalid because of this validation rule). |
Sure. However, the queries are also invalid because the variables are unused. Should we address that as well? Other validation tests don't, as far as I can tell. |
You need to also add this to the default list of validation rules in https://github.com/graphql/graphql-js/blob/master/src/validation/specifiedRules.js |
Otherwise this looks great. @jjergus do you want to also draft a PR to the spec to include this? |
it('duplicate variable names', () => { | ||
expectFailsRule(UniqueVariableNames, ` | ||
query A($x: Int, $x: Int, $x: String) { __typename } | ||
query B($x: String, $x: Int) { __typename } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps also include a test like query C($x: Int, $x: Int) { __typename }
just to illustrate that only duplicating a variable name is still not valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
Validate: Unique variable names
Excellent |
No description provided.