Skip to content

Commit 46f9ac6

Browse files
committed
Merge pull request #123 from facebook/covariance
[Schema] Implementing interfaces with covariant return types.
2 parents a6ae1a0 + 0b4fd58 commit 46f9ac6

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

spec/Section 3 -- Type System.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,20 @@ of rules must be adhered to by every Object type in a GraphQL schema.
408408
2. An object type must be a super-set of all interfaces it implements.
409409
1. The object type must include a field of the same name for every field
410410
defined in an interface.
411-
1. The object field must be of a type which is equal to the
412-
interface field (invariant).
411+
1. The object field must be of a type which is equal to or a sub-type of
412+
the interface field (covariant).
413+
1. An object field type is a valid sub-type if it is equal to (the same
414+
type as) the interface field type.
415+
2. An object field type is a valid sub-type if it is an Object type and
416+
the interface field type is either an Interface type or a Union type
417+
and the object field type is a possible type of the interface field
418+
type.
419+
3. An object field type is a valid sub-type if it is a List type and
420+
the interface field type is also a List type and the list-item type
421+
of the object field type is a valid sub-type of the list-item type
422+
of the interface field type.
423+
4. An object field type is a valid sub-type if it is a Non-Null variant
424+
of a valid sub-type of the interface field type.
413425
2. The object field must include an argument of the same name for every
414426
argument defined in the interface field.
415427
1. The object field argument must accept the same type (invariant) as

0 commit comments

Comments
 (0)