@@ -1448,6 +1448,60 @@ define arguments or contain references to interfaces and unions, neither of
1448
1448
which is appropriate for use as an input argument . For this reason , input
1449
1449
objects have a separate type in the system .
1450
1450
1451
+ **Circular References **
1452
+
1453
+ Input Objects are allowed to reference other Input Objects as field types . A
1454
+ circular reference occurs when an Input Object references itself either directly
1455
+ or through referenced Input Objects .
1456
+
1457
+ Circular references are generally allowed , however they may not be defined as an
1458
+ unbroken chain of Non -Null singular fields . Such Input Objects are invalid
1459
+ because there is no way to provide a legal value for them .
1460
+
1461
+ This example of a circularly -referenced input type is valid as the field `self `
1462
+ may be omitted or the value {null }.
1463
+
1464
+ ```graphql example
1465
+ input Example {
1466
+ self : Example
1467
+ value : String
1468
+ }
1469
+ ```
1470
+
1471
+ This example is also valid as the field `self ` may be an empty List .
1472
+
1473
+ ```graphql example
1474
+ input Example {
1475
+ self : [Example ! ]!
1476
+ value : String
1477
+ }
1478
+ ```
1479
+
1480
+ This example of a circularly -referenced input type is invalid as the field
1481
+ `self ` cannot be provided a finite value .
1482
+
1483
+ ```graphql counter -example
1484
+ input Example {
1485
+ value : String
1486
+ self : Example !
1487
+ }
1488
+ ```
1489
+
1490
+ This example is also invalid , as there is a non -null singular circular reference
1491
+ via the `First .second ` and `Second .first ` fields .
1492
+
1493
+ ```graphql counter -example
1494
+ input First {
1495
+ second : Second !
1496
+ value : String
1497
+ }
1498
+
1499
+ input Second {
1500
+ first : First !
1501
+ value : String
1502
+ }
1503
+ ```
1504
+
1451
1505
**Result Coercion **
1452
1506
1453
1507
An input object is never a valid result . Input Object types cannot be the return
@@ -1526,6 +1580,9 @@ Literal Value | Variables | Coerced Value
1526
1580
characters {"__" } (two underscores).
1527
1581
3. The input field must accept a type where {IsInputType (inputFieldType)}
1528
1582
returns {true }.
1583
+ 3. If an Input Object references itself either directly or through referenced
1584
+ Input Objects , at least one of the fields in the chain of references must be
1585
+ either a nullable or a List type .
1529
1586
1530
1587
1531
1588
### Input Object Extensions
0 commit comments