@@ -249,9 +249,10 @@ type in the system, allowing the definition of arbitrary type hierarchies.
249
249
250
250
GraphQL supports two abstract types: interfaces and unions.
251
251
252
- An ` Interface ` defines a list of fields; ` Object ` types that implement that
253
- interface are guaranteed to implement those fields. Whenever the type system
254
- claims it will return an interface, it will return a valid implementing type.
252
+ An ` Interface ` defines a list of fields; ` Object ` types and other Interface
253
+ types that implement the interface are guaranteed to implement those fields.
254
+ Whenever the type system claims it will return an interface, it will return a
255
+ valid implementing ` Object ` type.
255
256
256
257
A ` Union ` defines a list of possible types; similar to interfaces, whenever the
257
258
type system claims a union will be returned, one of the possible types will be
@@ -804,8 +805,8 @@ of rules must be adhered to by every Object type in a GraphQL schema.
804
805
characters {"__ "} (two underscores).
805
806
2 . The argument must accept a type where {IsInputType(argumentType)}
806
807
returns {true}.
807
- 4 . An object type may declare that it implements one or more unique interfaces.
808
- 5 . An object type must be a super-set of all interfaces it implements:
808
+ 3 . An object type may declare that it implements one or more unique interfaces.
809
+ 4 . An object type must be a super-set of all interfaces it implements:
809
810
1 . The object type must include a field of the same name for every field
810
811
defined in an interface.
811
812
1 . The object field must be of a type which is equal to or a sub-type of
@@ -816,11 +817,15 @@ of rules must be adhered to by every Object type in a GraphQL schema.
816
817
the interface field type is either an Interface type or a Union type
817
818
and the object field type is a possible type of the interface field
818
819
type.
819
- 3 . An object field type is a valid sub-type if it is a List type and
820
+ 3 . An object field type is a valid sub-type if it is an Interface type
821
+ and the interface field type is either an Interface type or a Union
822
+ type and the object field type is a possible type of the interface
823
+ field type.
824
+ 4 . An object field type is a valid sub-type if it is a List type and
820
825
the interface field type is also a List type and the list-item type
821
826
of the object field type is a valid sub-type of the list-item type
822
827
of the interface field type.
823
- 4 . An object field type is a valid sub-type if it is a Non-Null variant
828
+ 5 . An object field type is a valid sub-type if it is a Non-Null variant
824
829
of a valid sub-type of the interface field type.
825
830
2 . The object field must include an argument of the same name for every
826
831
argument defined in the interface field.
@@ -947,8 +952,8 @@ Object type extensions have the potential to be invalid if incorrectly defined.
947
952
InterfaceTypeDefinition : Description ? interface Name Directives [Const ]? FieldsDefinition ?
948
953
949
954
GraphQL interfaces represent a list of named fields and their arguments . GraphQL
950
- objects can then implement these interfaces which requires that the object type
951
- will define all fields defined by those interfaces .
955
+ objects and interfaces can then implement these interfaces which requires that
956
+ the object type will define all fields defined by those interfaces .
952
957
953
958
Fields on a GraphQL interface have the same rules as fields on a GraphQL object ;
954
959
their type can be Scalar , Object , Enum , Interface , or Union , or any wrapping
@@ -1038,6 +1043,22 @@ interface. Querying for `age` is only valid when the result of `entity` is a
1038
1043
}
1039
1044
```
1040
1045
1046
+ When defining an interface that implements another interface, the implementing
1047
+ interface must define each field that is specified by the implemented interface.
1048
+ For example, the interface Resource must define the field id to implement the
1049
+ Node interface:
1050
+
1051
+ ``` graphql example
1052
+ interface Node {
1053
+ id : ID !
1054
+ }
1055
+
1056
+ interface Resource implements Node {
1057
+ id : ID !
1058
+ url : String
1059
+ }
1060
+ ```
1061
+
1041
1062
**Result Coercion **
1042
1063
1043
1064
The interface type should have some way of determining which object a given
@@ -1065,6 +1086,38 @@ Interface types have the potential to be invalid if incorrectly defined.
1065
1086
characters {"__" } (two underscores).
1066
1087
2. The argument must accept a type where {IsInputType (argumentType)}
1067
1088
returns {true }.
1089
+ 3. An interface type may declare that it implements one or more unique
1090
+ interfaces , but may not implement itself .
1091
+ 4. An interface type must be a super -set of all interfaces it implements :
1092
+ 1. The implementing interface type must include a field of the same name for
1093
+ every field defined in an implemented interface .
1094
+ 1. The implementing interface field must be of a type which is equal to or
1095
+ a sub -type of the implemented interface field (covariant).
1096
+ 1. An implementing interface field type is a valid sub -type if it is
1097
+ equal to (the same type as) the implemented interface field type .
1098
+ 2. An implementing interface field type is a valid sub -type if it is an
1099
+ Object type and the implemented interface field type is either an
1100
+ Interface type or a Union type and the implementing interface field
1101
+ type is a possible type of the implemented interface field type .
1102
+ 3. An implementing interface field type is a valid sub -type if it is an
1103
+ Interface type and the implemented interface field type is either an
1104
+ Interface type or a Union type and the implementing interface field
1105
+ type is a possible type of the implemented interface field type .
1106
+ 4. An implementing interface field type is a valid sub -type if it is a
1107
+ List type and the implemented interface field type is also a List
1108
+ type and the list -item type of the implementing interface field type
1109
+ is a valid sub -type of the list -item type of the implemented
1110
+ interface field type .
1111
+ 5. An implementing interface field type is a valid sub -type if it is a
1112
+ Non -Null variant of a valid sub -type of the implemented interface
1113
+ field type .
1114
+ 2. The implementing interface field must include an argument of the same
1115
+ name for every argument defined in the implemented interface field .
1116
+ 1. The implementing interface field argument must accept the same type
1117
+ (invariant) as the implemented interface field argument .
1118
+ 3. The implementing interface field may include additional arguments not
1119
+ defined in the implemented interface field , but any additional argument
1120
+ must not be required .
1068
1121
1069
1122
1070
1123
### Interface Extensions
@@ -1114,10 +1167,12 @@ Interface type extensions have the potential to be invalid if incorrectly define
1114
1167
fields may share the same name .
1115
1168
3. Any fields of an Interface type extension must not be already defined on the
1116
1169
original Interface type .
1117
- 4. Any Object type which implemented the original Interface type must also be a
1118
- super -set of the fields of the Interface type extension (which may be due to
1119
- Object type extension).
1170
+ 4. Any Object or Interface type which implemented the original Interface type
1171
+ must also be a super -set of the fields of the Interface type extension (which
1172
+ may be due to Object type extension).
1120
1173
5. Any directives provided must not already apply to the original Interface type .
1174
+ 6. The resulting extended interface type must be a super -set of all interfaces
1175
+ it implements .
1121
1176
1122
1177
1123
1178
## Unions
0 commit comments