Skip to content

Commit

Permalink
Move note and clarify algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Nov 9, 2023
1 parent 07d936e commit ef70568
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
20 changes: 16 additions & 4 deletions spec/Section 3 -- Type System.md
Original file line number Diff line number Diff line change
Expand Up @@ -1792,14 +1792,26 @@ CoerceListItemValue(itemValue, itemType):

- If {itemValue} is {null}, return {null}.
- Otherwise, if {itemValue} is a Variable:
- Let {runtimeValue} be the runtime value of that variable, or {null} if no
runtime value is provided.
- If {runtimeValue} is {null} and {itemType} is a non-null type, a _field
- If the variable provides a runtime value:
- Let {coercedItemValue} be the runtime value of the variable.
- Otherwise, if the variable definition provides a default value:
- Let {coercedItemValue} be this default value.
- Otherwise:
- Let {coercedItemValue} be {null}.
- If {coercedItemValue} is {null} and {itemType} is a non-null type, a _field
error_ must be raised.
- Return {runtimeValue}.
- Return {coercedItemValue}.
- Otherwise, return the result of coercing {itemValue} according to the input
coercion rules for {itemType}.

Note: When a default value exists for a variable definition, the type of the
variable is allowed to be nullable even if it is used in a non-nullable
position, see
[Allowing Optional Variables When Default Values Exist](#sec-All-Variable-Usages-Are-Allowed.Allowing-Optional-Variables-When-Default-Values-Exist)
in Validation. If the value for such a variable is explicitly {null} and is used
as the value for a list item of non-nullable type then a _field error_ will be
raised.

Following are examples of input coercion with various list types and values:

| Expected Type | Literal Value | Variable Values | Coerced Value |
Expand Down
7 changes: 0 additions & 7 deletions spec/Section 6 -- Execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,6 @@ Note: Variable values are not coerced because they are expected to be coerced
before executing the operation in {CoerceVariableValues()}, and valid operations
must only allow usage of variables of appropriate types.

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

### Value Resolution

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

0 comments on commit ef70568

Please sign in to comment.