Skip to content

Commit ce40773

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

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

spec/Section 3 -- Type System.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,18 +1373,22 @@ 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 explicitly included within the parent union, i.e. if
1377+
a parent union includes a child union, all types included by the child union
1378+
must be explicitly included by the parent union. Similarly, if a union includes
1379+
an interface, all types implementing the interface must be explicitly included
1380+
by the union.
1381+
1382+
For example, the following types are valid:
13791383

13801384
```graphql example
1381-
union SearchResult = Item | Photo | Video | Named
1385+
union SearchResult = Item | Photo | Video | Named | Person
13821386

13831387
interface Named {
13841388
name: String
13851389
}
13861390

1387-
type Person {
1391+
type Person implements Named {
13881392
name: String
13891393
age: Int
13901394
}
@@ -1426,11 +1430,18 @@ And, given the above, the following operation is valid:
14261430
}
14271431
```
14281432

1429-
While the following union is invalid, because the member types of `Item` are not
1430-
explicitly included within `SearchResult`:
1433+
While the following union is invalid, because `Photo` and `Video` are contained
1434+
by the union `Item` and are not explicitly included within `SearchResult`:
1435+
1436+
```graphql counter-example
1437+
union SearchResult = Item | Named | Person
1438+
```
1439+
1440+
The following union is also invalid, because `Person` implements `Named`, but is
1441+
not explicitly included within `SearchResult`:
14311442

14321443
```graphql counter-example
1433-
union SearchResult = Item | Named
1444+
union SearchResult = Item | Photo | Video | Named
14341445
```
14351446

14361447
**Result Coercion**

0 commit comments

Comments
 (0)