Skip to content

Commit 794e699

Browse files
committed
[RFC] Move input field uniqueness validator
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.
1 parent e67a987 commit 794e699

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

spec/Section 2 -- Language.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,6 @@ ObjectValue : { ObjectField+ }
712712
* Let {inputObject} be a new input object value with no fields.
713713
* For each {field} in {ObjectField+}
714714
* Let {name} be {Name} in {field}.
715-
* If {inputObject} contains a field named {name} throw Syntax Error.
716715
* Let {value} be the result of evaluating {Value} in {field}.
717716
* Add a field to {inputObject} of name {name} containing value {value}.
718717
* Return {inputObject}

spec/Section 5 -- Validation.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,31 @@ fragment sentientFragment on Sentient {
10281028
is not valid because there exists no type that implements both {Pet}
10291029
and {Sentient}.
10301030

1031+
## Values
1032+
1033+
### Input Object Field Uniqueness
1034+
1035+
** Formal Specification **
1036+
1037+
* For each input object value {inputObject} in the document.
1038+
* For every {inputField} in {inputObject}
1039+
* Let {name} be the Name of {inputField}.
1040+
* Let {fields} be all Input Object Fields named {name} in {inputObject}.
1041+
* {fields} must be the set containing only {inputField}.
1042+
1043+
** Explanatory Text **
1044+
1045+
Input objects must not contain more than one fields of the same name, otherwise
1046+
an amgibuity would exist which includes an ignored portion of syntax.
1047+
1048+
For example the following query will not pass validation.
1049+
1050+
```graphql
1051+
{
1052+
field(arg: { field: true, field: false })
1053+
}
1054+
```
1055+
10311056
## Directives
10321057

10331058
### Directives Are Defined

0 commit comments

Comments
 (0)