@@ -882,6 +882,8 @@ of rules must be adhered to by every Object type in a GraphQL schema.
882
882
returns {true }.
883
883
3. If argument type is Non -Null and a default value is not defined :
884
884
- The `@deprecated ` directive must not be applied to this argument .
885
+ 4. If the argument has a default value , it must be compatible with
886
+ {argumentType } as per the coercion rules for that type .
885
887
3. An object type may declare that it implements one or more unique interfaces .
886
888
4. An object type must be a super -set of all interfaces it implements :
887
889
1. Let this object type be {objectType }.
@@ -1598,7 +1600,8 @@ defined by the input object type and for which a value exists. The resulting map
1598
1600
is constructed with the following rules :
1599
1601
1600
1602
- If no value is provided for a defined input object field and that field
1601
- definition provides a default value , the default value should be used . If no
1603
+ definition provides a default value , the result of coercing the default value
1604
+ according to the coercion rules of the input field type should be used . If no
1602
1605
default value is provided and the input object field 's type is non -null , an
1603
1606
error should be raised . Otherwise , if the field is not required , then no entry
1604
1607
is added to the coerced unordered map .
@@ -1663,6 +1666,42 @@ input ExampleInputObject {
1663
1666
3. If an Input Object references itself either directly or through referenced
1664
1667
Input Objects , at least one of the fields in the chain of references must be
1665
1668
either a nullable or a List type .
1669
+ 4. {DetectInputObjectDefaultValueCycle (inputObject)}.
1670
+
1671
+ DetectInputObjectDefaultValueCycle (inputObject, defaultValue, visitedFields):
1672
+
1673
+ - If {defaultValue } is not provided , initialize it to an empty unordered map .
1674
+ - If {visitedFields } is not provided , initialize it to the empty set .
1675
+ - If {defaultValue } is a list :
1676
+ - For each {itemValue } in {defaultValue }:
1677
+ - {DetectInputObjectDefaultValueCycle (inputObject, itemValue,
1678
+ visitedFields)}.
1679
+ - Otherwise :
1680
+ - If {defaultValue } is not an unordered map :
1681
+ - Return .
1682
+ - For each field {field } in {inputObject }:
1683
+ - {DetectInputFieldDefaultValueCycle (field, defaultValue, visitedFields)}.
1684
+
1685
+ DetectInputFieldDefaultValueCycle (field, defaultValue, visitedFields):
1686
+
1687
+ - Assert : {defaultValue } is an unordered map .
1688
+ - Let {fieldType } be the type of {field }.
1689
+ - Let {namedFieldType } be the underlying named type of {fieldType }.
1690
+ - If {namedFieldType } is not an input object type :
1691
+ - Return .
1692
+ - Let {fieldName } be the name of {field }.
1693
+ - Let {fieldDefaultValue } be the value for {fieldName } in {defaultValue }.
1694
+ - If {fieldDefaultValue } exists :
1695
+ - {DetectInputObjectDefaultValueCycle (namedFieldType, fieldDefaultValue,
1696
+ visitedFields)}.
1697
+ - Otherwise :
1698
+ - Let {fieldDefaultValue } be the default value of {field }.
1699
+ - If {fieldDefaultValue } does not exist :
1700
+ - Return .
1701
+ - {field } must not be within {visitedFields }.
1702
+ - Add {field } to {visitedFields }.
1703
+ - {DetectInputObjectDefaultValueCycle (namedFieldType, fieldDefaultValue,
1704
+ visitedFields)}.
1666
1705
1667
1706
### Input Object Extensions
1668
1707
0 commit comments