Skip to content

Commit

Permalink
[RFC] Move input field uniqueness validator
Browse files Browse the repository at this point in the history
This proposes moving input field uniqueness assertion from the parser to the validator. This simplifies the parser and allows these errors to be reported as part of the collection of validation errors which is actually more valuable.
  • Loading branch information
leebyron committed Sep 24, 2015
1 parent e67a987 commit 794e699
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion spec/Section 2 -- Language.md
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,6 @@ ObjectValue : { ObjectField+ }
* Let {inputObject} be a new input object value with no fields.
* For each {field} in {ObjectField+}
* Let {name} be {Name} in {field}.
* If {inputObject} contains a field named {name} throw Syntax Error.
* Let {value} be the result of evaluating {Value} in {field}.
* Add a field to {inputObject} of name {name} containing value {value}.
* Return {inputObject}
Expand Down
25 changes: 25 additions & 0 deletions spec/Section 5 -- Validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,31 @@ fragment sentientFragment on Sentient {
is not valid because there exists no type that implements both {Pet}
and {Sentient}.

## Values

### Input Object Field Uniqueness

** Formal Specification **

* For each input object value {inputObject} in the document.
* For every {inputField} in {inputObject}
* Let {name} be the Name of {inputField}.
* Let {fields} be all Input Object Fields named {name} in {inputObject}.
* {fields} must be the set containing only {inputField}.

** Explanatory Text **

Input objects must not contain more than one fields of the same name, otherwise
an amgibuity would exist which includes an ignored portion of syntax.

For example the following query will not pass validation.

```graphql
{
field(arg: { field: true, field: false })
}
```

## Directives

### Directives Are Defined
Expand Down

0 comments on commit 794e699

Please sign in to comment.