Skip to content
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

Merged
merged 1 commit into from
Feb 18, 2016
Merged

Validate: Unique variable names #296

merged 1 commit into from
Feb 18, 2016

Conversation

jjergus
Copy link
Contributor

@jjergus jjergus commented Feb 17, 2016

No description provided.

@dschafer
Copy link
Contributor

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).

@jjergus
Copy link
Contributor Author

jjergus commented Feb 17, 2016

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.

@leebyron
Copy link
Contributor

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

@leebyron
Copy link
Contributor

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 }
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jjergus
Copy link
Contributor Author

jjergus commented Feb 18, 2016

do you want to also draft a PR to the spec to include this?

graphql/graphql-spec#145

leebyron added a commit that referenced this pull request Feb 18, 2016
Validate: Unique variable names
@leebyron leebyron merged commit fd8598d into graphql:master Feb 18, 2016
@leebyron
Copy link
Contributor

Excellent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants