Skip to content

Commit 8eaa45b

Browse files
committed
Reflect that variable values should already be coerced, and thus applying their defaults is redundant.
1 parent fba35d5 commit 8eaa45b

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

spec/Section 3 -- Type System.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,9 +1638,9 @@ defined by the input object type and for which a value exists. The resulting map
16381638
is constructed with the following rules:
16391639

16401640
- If no value is provided for a defined input object field and that field
1641-
definition provides a default value, the default value should be used. If no
1641+
definition provides a default value, the default value must be used. If no
16421642
default value is provided and the input object field's type is non-null, an
1643-
error should be raised. Otherwise, if the field is not required, then no entry
1643+
error must be raised. Otherwise, if the field is not required, then no entry
16441644
is added to the coerced unordered map.
16451645

16461646
- If the value {null} was provided for an input object field, and the field's
@@ -1652,12 +1652,17 @@ is constructed with the following rules:
16521652
coerced unordered map is given the result of coercing that value according to
16531653
the input coercion rules for the type of that field.
16541654

1655-
- If a variable is provided for an input object field, the runtime value of that
1656-
variable must be used. If the runtime value is {null} and the field type is
1657-
non-null, a _field error_ must be raised. If no runtime value is provided, the
1658-
variable definition's default value should be used. If the variable definition
1659-
does not provide a default value, the input object field definition's default
1660-
value should be used.
1655+
- If a variable is provided for an input object field:
1656+
1657+
- If the _coerced runtime value_ of that variable exists then it must be used.
1658+
If the coerced runtime value is {null} and the field type is non-null, a
1659+
_field error_ must be raised.
1660+
1661+
- If the _coerced runtime value_ of that variable does not exist then the
1662+
input object field definition's default value must be used. If no default
1663+
value is provided and the input object field's type is non-null, an error
1664+
must be raised. Otherwise, if the field is not required, then no entry is
1665+
added to the coerced unordered map.
16611666

16621667
Following are examples of input coercion for an input object type with a
16631668
`String` field `a` and a required (non-null) `Int!` field `b`:
@@ -1791,12 +1796,8 @@ CoerceListValue(value, listType):
17911796
CoerceListItemValue(itemValue, itemType):
17921797

17931798
- If {itemValue} is a Variable:
1794-
- If the variable provides a runtime value:
1795-
- Let {coercedItemValue} be the runtime value of the variable.
1796-
- Otherwise, if the variable definition provides a default value:
1797-
- Let {coercedItemValue} be this default value.
1798-
- Otherwise:
1799-
- Let {coercedItemValue} be {null}.
1799+
- Let {coercedItemValue} be the _coerced runtime value_ of that variable, or
1800+
{null} if no such value exists.
18001801
- If {coercedItemValue} is {null} and {itemType} is a non-null type, a _field
18011802
error_ must be raised.
18021803
- Return {coercedItemValue}.

spec/Section 6 -- Execution.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ need to be coerced using the input coercion rules of variable's declared type.
8181
If a _request error_ is encountered during input coercion of variable values,
8282
then the operation fails without execution.
8383

84+
:: The _coerced runtime value_ of a variable is the entry matching the
85+
variable's name in the result of {CoerceVariableValues()}, if any.
86+
8487
CoerceVariableValues(schema, operation, variableValues):
8588

8689
- Let {coercedValues} be an empty unordered Map.

0 commit comments

Comments
 (0)