Skip to content

Commit 31e592e

Browse files
committed
add requirement that implementions of interfaces included by unions must be explicitly listed within the union
1 parent 2a4d3ed commit 31e592e

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

spec/Section 3 -- Type System.md

+17-8
Original file line numberDiff line numberDiff line change
@@ -1373,18 +1373,20 @@ union SearchResult =
13731373
**Unions of Interfaces and Unions**
13741374

13751375
A Union may declare interfaces or other unions as member types. Transitively
1376-
included object types (object types included within a union included by a union)
1377-
must also be included within the parent union. For example, the following types
1378-
are valid:
1376+
included types must also be included within the parent union. If a parent union
1377+
includes a child union, all types included by the child union must be included
1378+
by the parent union. Similarly, if a union includes an interface, all types
1379+
implementing the interface must be included by the union. For example, the
1380+
following types are valid:
13791381

13801382
```graphql example
1381-
union SearchResult = Item | Photo | Video | Named
1383+
union SearchResult = Item | Photo | Video | Named | Person
13821384

13831385
interface Named {
13841386
name: String
13851387
}
13861388

1387-
type Person {
1389+
type Person implements Named {
13881390
name: String
13891391
age: Int
13901392
}
@@ -1426,11 +1428,18 @@ And, given the above, the following operation is valid:
14261428
}
14271429
```
14281430

1429-
While the following union is invalid, because the member types of `Item` are not
1430-
explicitly included within `SearchResult`:
1431+
While the following union is invalid, because `Photo` and `Video` are contained
1432+
by the union `Item` and are not explicitly included within `SearchResult`:
14311433

14321434
```graphql counter-example
1433-
union SearchResult = Item | Named
1435+
union SearchResult = Item | Named | Person
1436+
```
1437+
1438+
The following union is also invalid, because `Person` implements `Named`, but is
1439+
not explicitly included within `SearchResult`:
1440+
1441+
```graphql counter-example
1442+
union SearchResult = Item | Photo | Video | Named
14341443
```
14351444

14361445
**Result Coercion**

0 commit comments

Comments
 (0)