@@ -1373,18 +1373,20 @@ union SearchResult =
1373
1373
**Unions of Interfaces and Unions **
1374
1374
1375
1375
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 :
1379
1381
1380
1382
```graphql example
1381
- union SearchResult = Item | Photo | Video | Named
1383
+ union SearchResult = Item | Photo | Video | Named | Person
1382
1384
1383
1385
interface Named {
1384
1386
name : String
1385
1387
}
1386
1388
1387
- type Person {
1389
+ type Person implements Named {
1388
1390
name : String
1389
1391
age : Int
1390
1392
}
@@ -1426,11 +1428,18 @@ And, given the above, the following operation is valid:
1426
1428
}
1427
1429
```
1428
1430
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 `:
1431
1433
1432
1434
```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
1434
1443
```
1435
1444
1436
1445
**Result Coercion **
0 commit comments