From ef705688d952fdc097c8a76aa4e1417a958d687a Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Thu, 9 Nov 2023 17:14:38 +0000 Subject: [PATCH] Move note and clarify algorithm --- spec/Section 3 -- Type System.md | 20 ++++++++++++++++---- spec/Section 6 -- Execution.md | 7 ------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/spec/Section 3 -- Type System.md b/spec/Section 3 -- Type System.md index 6c4399af1..fd2ac2663 100644 --- a/spec/Section 3 -- Type System.md +++ b/spec/Section 3 -- Type System.md @@ -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 | diff --git a/spec/Section 6 -- Execution.md b/spec/Section 6 -- Execution.md index febadf884..f357069f9 100644 --- a/spec/Section 6 -- Execution.md +++ b/spec/Section 6 -- Execution.md @@ -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