Skip to content

Commit 9165c89

Browse files
committed
More thorough consideration
1 parent faa9af1 commit 9165c89

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

spec/Section 3 -- Type System.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,8 @@ of rules must be adhered to by every Object type in a GraphQL schema.
818818
characters {"__"} (two underscores).
819819
2. The argument must accept a type where {IsInputType(argumentType)}
820820
returns {true}.
821+
3. If specified, {defaultValue} must be compatible with {argumentType}
822+
as per the coercion rules for that type.
821823
3. An object type may declare that it implements one or more unique interfaces.
822824
4. An object type must be a super-set of all interfaces it implements:
823825
1. Let this object type be {objectType}.
@@ -1466,10 +1468,12 @@ defined by the input object type and for which a value exists. The resulting map
14661468
is constructed with the following rules:
14671469

14681470
* If no value is provided for a defined input object field and that field
1469-
definition provides a default value, the default value should be used. If no
1470-
default value is provided and the input object field's type is non-null, an
1471-
error should be thrown. Otherwise, if the field is not required, then no entry
1472-
is added to the coerced unordered map.
1471+
definition provides a default value, the result of coercing the default value
1472+
according to the coercion rules of the input field type should be used (if
1473+
this coercion would cause an infinite loop, a query error should be thrown).
1474+
If no default value is provided and the input object field's type is
1475+
non-null, an error should be thrown. Otherwise, if the field is not required,
1476+
then no entry is added to the coerced unordered map.
14731477

14741478
* If the value {null} was provided for an input object field, and the field's
14751479
type is not a non-null type, an entry in the coerced unordered map is given
@@ -1526,6 +1530,8 @@ Literal Value | Variables | Coerced Value
15261530
characters {"__"} (two underscores).
15271531
3. The input field must accept a type where {IsInputType(inputFieldType)}
15281532
returns {true}.
1533+
4. If specified, {defaultValue} must be compatible with {inputFieldType} as
1534+
per the coercion rules for that type.
15291535

15301536

15311537
### Input Object Extensions

spec/Section 6 -- Execution.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ CoerceVariableValues(schema, operation, variableValues):
8989
* Let {value} be the value provided in {variableValues} for the
9090
name {variableName}.
9191
* If {hasValue} is not {true} and {defaultValue} exists (including {null}):
92-
* If {defaultValue} cannot be coerced according to the input coercion
93-
rules of {variableType}, throw a query error.
9492
* Let {coercedDefaultValue} be the result of coercing {defaultValue} according to the
9593
input coercion rules of {variableType}.
9694
* Add an entry to {coercedValues} named {variableName} with the
@@ -590,10 +588,8 @@ CoerceArgumentValues(objectType, field, variableValues):
590588
name {variableName}.
591589
* Otherwise, let {value} be {argumentValue}.
592590
* If {hasValue} is not {true} and {defaultValue} exists (including {null}):
593-
* If {defaultValue} cannot be coerced according to the input coercion
594-
rules of {variableType}, throw a query error.
595591
* Let {coercedDefaultValue} be the result of coercing {defaultValue} according to the
596-
input coercion rules of {variableType}.
592+
input coercion rules of {argumentType}.
597593
* Add an entry to {coercedValues} named {argumentName} with the
598594
value {coercedDefaultValue}.
599595
* Otherwise if {argumentType} is a Non-Nullable type, and either {hasValue}

0 commit comments

Comments
 (0)