Skip to content

Commit 4a2aadc

Browse files
committed
update introspection and validation
1 parent 972f2cb commit 4a2aadc

File tree

3 files changed

+72
-18
lines changed

3 files changed

+72
-18
lines changed

spec/Section 3 -- Type System.md

+67-12
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,10 @@ type in the system, allowing the definition of arbitrary type hierarchies.
249249

250250
GraphQL supports two abstract types: interfaces and unions.
251251

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.
255256

256257
A `Union` defines a list of possible types; similar to interfaces, whenever the
257258
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.
804805
characters {"__"} (two underscores).
805806
2. The argument must accept a type where {IsInputType(argumentType)}
806807
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:
809810
1. The object type must include a field of the same name for every field
810811
defined in an interface.
811812
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.
816817
the interface field type is either an Interface type or a Union type
817818
and the object field type is a possible type of the interface field
818819
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
820825
the interface field type is also a List type and the list-item type
821826
of the object field type is a valid sub-type of the list-item type
822827
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
824829
of a valid sub-type of the interface field type.
825830
2. The object field must include an argument of the same name for every
826831
argument defined in the interface field.
@@ -947,8 +952,8 @@ Object type extensions have the potential to be invalid if incorrectly defined.
947952
InterfaceTypeDefinition : Description? interface Name Directives[Const]? FieldsDefinition?
948953

949954
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.
952957

953958
Fields on a GraphQL interface have the same rules as fields on a GraphQL object;
954959
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
10381043
}
10391044
```
10401045

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+
10411062
**Result Coercion**
10421063

10431064
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.
10651086
characters {"__"} (two underscores).
10661087
2. The argument must accept a type where {IsInputType(argumentType)}
10671088
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.
10681121

10691122

10701123
### Interface Extensions
@@ -1114,10 +1167,12 @@ Interface type extensions have the potential to be invalid if incorrectly define
11141167
fields may share the same name.
11151168
3. Any fields of an Interface type extension must not be already defined on the
11161169
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).
11201173
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.
11211176

11221177

11231178
## Unions

spec/Section 4 -- Introspection.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ type __Type {
131131

132132
# OBJECT and INTERFACE only
133133
fields(includeDeprecated: Boolean = false): [__Field!]
134-
135-
# OBJECT only
136134
interfaces: [__Type!]
137135

138136
# INTERFACE and UNION only
@@ -291,6 +289,7 @@ Fields
291289
* `fields`: The set of fields required by this interface.
292290
* Accepts the argument `includeDeprecated` which defaults to {false}. If
293291
{true}, deprecated fields are also returned.
292+
* `interfaces`: The set of interfaces that an interface implements.
294293
* `possibleTypes` returns the list of types that implement this interface.
295294
They must be object types.
296295
* All other fields must return {null}.

spec/Section 5 -- Validation.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,8 @@ fragment catInDogFragmentInvalid on Dog {
11311131

11321132
##### Abstract Spreads in Object Scope
11331133

1134-
In scope of an object type, unions or interface spreads can be used
1135-
if the object type implements the interface or is a member of the union.
1134+
In scope of an object or interface type, unions or interface spreads can be
1135+
used if the type implements the interface or is a member of the union.
11361136

11371137
For example
11381138

@@ -1172,8 +1172,8 @@ declaration, not its body.
11721172
##### Object Spreads In Abstract Scope
11731173

11741174
Union or interface spreads can be used within the context of an object type
1175-
fragment, but only if the object type is one of the possible types of
1176-
that interface or union.
1175+
fragment or interface type fragment, but only if the type is one of the
1176+
possible types of that interface or union.
11771177

11781178
For example, the following fragments are valid:
11791179

0 commit comments

Comments
 (0)