Skip to content

Commit ec3d50a

Browse files
committed
Move note and clarify algorithm
1 parent 4ca2023 commit ec3d50a

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

spec/Section 3 -- Type System.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,14 +1792,26 @@ CoerceListItemValue(itemValue, itemType):
17921792

17931793
- If {itemValue} is {null}, return {null}.
17941794
- Otherwise, if {itemValue} is a Variable:
1795-
- Let {runtimeValue} be the runtime value of that variable, or {null} if no
1796-
runtime value is provided.
1797-
- If {runtimeValue} is {null} and {itemType} is a non-null type, a _field
1795+
- If the variable provides a runtime value:
1796+
- Let {coercedItemValue} be the runtime value of the variable.
1797+
- Otherwise, if the variable definition provides a default value:
1798+
- Let {coercedItemValue} be this default value.
1799+
- Otherwise:
1800+
- Let {coercedItemValue} be {null}.
1801+
- If {coercedItemValue} is {null} and {itemType} is a non-null type, a _field
17981802
error_ must be raised.
1799-
- Return {runtimeValue}.
1803+
- Return {coercedItemValue}.
18001804
- Otherwise, return the result of coercing {itemValue} according to the input
18011805
coercion rules for {itemType}.
18021806

1807+
Note: When a default value exists for a variable definition, the type of the
1808+
variable is allowed to be nullable even if it is used in a non-nullable
1809+
position, see
1810+
[Allowing Optional Variables When Default Values Exist](#sec-All-Variable-Usages-Are-Allowed.Allowing-Optional-Variables-When-Default-Values-Exist)
1811+
in Validation. If the value for such a variable is explicitly {null} and is used
1812+
as the value for a list item of non-nullable type then a _field error_ will be
1813+
raised.
1814+
18031815
Following are examples of input coercion with various list types and values:
18041816

18051817
| Expected Type | Literal Value | Variable Values | Coerced Value |

spec/Section 6 -- Execution.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -645,13 +645,6 @@ Note: Variable values are not coerced because they are expected to be coerced
645645
before executing the operation in {CoerceVariableValues()}, and valid operations
646646
must only allow usage of variables of appropriate types.
647647

648-
Note: When a default value exists for a variable definition, the type of the
649-
variable is allowed to be nullable even if it is used in a non-nullable
650-
position, see
651-
[Allowing Optional Variables When Default Values Exist](#sec-All-Variable-Usages-Are-Allowed.Allowing-Optional-Variables-When-Default-Values-Exist)
652-
in Validation. If the value for a variable is explicitly {null} and is used in a
653-
non-nullable position, a _field error_ will be raised.
654-
655648
### Value Resolution
656649

657650
While nearly all of GraphQL execution can be described generically, ultimately

0 commit comments

Comments
 (0)