@@ -272,6 +272,34 @@ referred to as "named types". A wrapping type has an underlying named type,
272272found by continually unwrapping the type until a named type is found.
273273
274274
275+ ### Input and Output Types
276+
277+ Types are used throughout GraphQL to describe both the values accepted as input
278+ to arguments and variables as well as the values output by fields. These two
279+ uses categorize types as * input types* and * output types* . Some kinds of types,
280+ like Scalar and Enum types, can be used as both input types and output types;
281+ other kinds types can only be used in one or the other. Input Object types can
282+ only be used as input types. Object, Interface, and Union types can only be used
283+ as output types. Lists and Non-Null types may be used as input types or output
284+ types depending on how the wrapped type may be used.
285+
286+ IsInputType(type) :
287+ * If {type} is a List type or Non-Null type:
288+ * Let {unwrappedType} be the unwrapped type of {type}.
289+ * Return IsInputType({unwrappedType})
290+ * If {type} is a Scalar, Enum, or Input Object type:
291+ * Return {true}
292+ * Return {false}
293+
294+ IsOutputType(type) :
295+ * If {type} is a List type or Non-Null type:
296+ * Let {unwrappedType} be the unwrapped type of {type}.
297+ * Return IsOutputType({unwrappedType})
298+ * If {type} is a Scalar, Object, Interface, Union, or Enum type:
299+ * Return {true}
300+ * Return {false}
301+
302+
275303### Type Extensions
276304
277305TypeExtension :
@@ -757,10 +785,16 @@ Object types have the potential to be invalid if incorrectly defined. This set
757785of rules must be adhered to by every Object type in a GraphQL schema.
758786
7597871 . An Object type must define one or more fields.
760- 2 . The fields of an Object type must have unique names within that Object type;
761- no two fields may share the same name.
762- 3 . Each field of an Object type must not have a name which begins with the
763- characters {"__ "} (two underscores).
788+ 2 . For each field of an Object type:
789+ 1 . The field must have a unique name within that Object type;
790+ no two fields may share the same name.
791+ 2 . The field must not have a name which begins with the
792+ characters {"__ "} (two underscores).
793+ 3 . The field must return a type where {IsOutputType(fieldType)} returns {true}.
794+ 4 . For each argument of the field:
795+ 1 . The argument must not have a name which begins with the
796+ characters {"__ "} (two underscores).
797+ 2 . The argument must accept a type where {IsInputType(argumentType)} returns {true}.
7647984 . An object type may declare that it implements one or more unique interfaces.
7657995 . An object type must be a super-set of all interfaces it implements:
766800 1 . The object type must include a field of the same name for every field
@@ -834,7 +868,8 @@ May yield the result:
834868}
835869```
836870
837- The type of an object field argument can be any Input type.
871+ The type of an object field argument must be an input type (any type except an
872+ Object, Interface, or Union type).
838873
839874
840875### Field Deprecation
@@ -1009,10 +1044,18 @@ Interfaces are never valid inputs.
10091044Interface types have the potential to be invalid if incorrectly defined.
10101045
101110461 . An Interface type must define one or more fields.
1012- 2 . The fields of an Interface type must have unique names within that Interface
1013- type; no two fields may share the same name.
1014- 3 . Each field of an Interface type must not have a name which begins with the
1015- characters {"__ "} (two underscores).
1047+ 2 . For each field of an Interface type:
1048+ 1 . The field must have a unique name within that Interface type;
1049+ no two fields may share the same name.
1050+ 2 . The field must not have a name which begins with the
1051+ characters {"__ "} (two underscores).
1052+ 3 . The field must return a type where {IsOutputType(fieldType)}
1053+ returns {true}.
1054+ 4 . For each argument of the field:
1055+ 1 . The argument must not have a name which begins with the
1056+ characters {"__ "} (two underscores).
1057+ 2 . The argument must accept a type where {IsInputType(argumentType)}
1058+ returns {true}.
10161059
10171060
10181061### Interface Extensions
@@ -1360,9 +1403,13 @@ Literal Value | Variables | Coerced Value
13601403**Type Validation **
13611404
136214051. An Input Object type must define one or more input fields .
1363- 2. The fields of an Input Object type must have unique names within that
1364- Input Object type ; no two fields may share the same name .
1365- 3. The return types of each defined field must be an Input type .
1406+ 2. For each input field of an Input Object type :
1407+ 1. The input field must have a unique name within that Input Object type ;
1408+ no two input fields may share the same name .
1409+ 2. The input field must not have a name which begins with the
1410+ characters {"__" } (two underscores).
1411+ 3. The input field must accept a type where {IsInputType (inputFieldType)}
1412+ returns {true }.
13661413
13671414
13681415### Input Object Extensions
0 commit comments