@@ -1398,26 +1398,47 @@ in square brackets like this: `pets: [Pet]`.
1398
1398
1399
1399
GraphQL servers must return an ordered list as the result of a list type . Each
1400
1400
item in the list must be the result of a result coercion of the item type . If a
1401
- reasonable coercion is not possible they must raise a field error . In
1401
+ reasonable coercion is not possible it must raise a field error . In
1402
1402
particular , if a non -list is returned , the coercion should fail , as this
1403
1403
indicates a mismatch in expectations between the type system and the
1404
1404
implementation .
1405
1405
1406
+ If a list 's item type is nullable , then errors occuring during preparation or
1407
+ coercion of an individual item in the list must result in a the value {null } at
1408
+ that position in the list along with an error added to the response . If a list 's
1409
+ item type is non -null , an error occuring at an individual item in the list must
1410
+ result in a field error for the entire list .
1411
+
1412
+ Note : For more information on the error handling process , see "Errors and
1413
+ Non-Nullability" within the Execution section .
1414
+
1406
1415
**Input Coercion **
1407
1416
1408
1417
When expected as an input , list values are accepted only when each item in the
1409
1418
list can be accepted by the list 's item type .
1410
1419
1411
1420
If the value passed as an input to a list type is *not * a list and not the
1412
- {null } value , it should be coerced as though the input was a list of size one ,
1413
- where the value passed is the only item in the list . This is to allow inputs
1414
- that accept a "var args" to declare their input type as a list ; if only one
1415
- argument is passed (a common case), the client can just pass that value rather
1416
- than constructing the list .
1417
-
1418
- Note that when a {null } value is provided via a runtime variable value for a
1419
- list type , the value is interpreted as no list being provided , and not a list of
1420
- size one with the value {null }.
1421
+ {null } value , then the result of input coercion is a list of size one ,
1422
+ where the single item value is the result of input coercion for the list 's item
1423
+ type on the provided value (note this may apply recursively for nested lists).
1424
+
1425
+ This allow inputs which accept one or many arguments (sometimes referred to as
1426
+ "var args" ) to declare their input type as a list while for the common case of a
1427
+ single value , a client can just pass that value directly rather than
1428
+ constructing the list .
1429
+
1430
+ Following are examples of input coercion with various list types and values :
1431
+
1432
+ Expected Type | Provided Value | Coerced Value
1433
+ ------------- | ---------------- | ---------------------------
1434
+ `[Int ]` | `[1, 2, 3]` | `[1, 2, 3]`
1435
+ `[Int ]` | `[1, "b" , true ]` | Error : Incorrect item value
1436
+ `[Int ]` | `1` | `[1]`
1437
+ `[Int ]` | `null ` | `null `
1438
+ `[[Int ]]` | `[[1], [2, 3]]` | `[[1], [2, 3]`
1439
+ `[[Int ]]` | `[1, 2, 3]` | Error : Incorrect item value
1440
+ `[[Int ]]` | `1` | `[[1]]`
1441
+ `[[Int ]]` | `null ` | `null `
1421
1442
1422
1443
1423
1444
## Non-Null
0 commit comments