@@ -1372,12 +1372,13 @@ union SearchResult =
1372
1372
1373
1373
**Unions of Interfaces and Unions **
1374
1374
1375
- A Union may declare interfaces or other unions as member types . The parent
1376
- Union 's possible types transitively include all the possible types of any
1377
- abstract member types . For example , the following types are valid :
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 :
1378
1379
1379
1380
```graphql example
1380
- union SearchResult = Photo | Named
1381
+ union SearchResult = Item | Photo | Video | Named
1381
1382
1382
1383
interface Named {
1383
1384
name : String
@@ -1425,6 +1426,13 @@ And, given the above, the following operation is valid:
1425
1426
}
1426
1427
```
1427
1428
1429
+ While the following union is invalid , because the member types of `Item ` are not
1430
+ explicitly included within `SearchResult `:
1431
+
1432
+ ```graphql counter -example
1433
+ union SearchResult = Item | Named
1434
+ ```
1435
+
1428
1436
**Result Coercion **
1429
1437
1430
1438
The union type should have some way of determining which object a given result
@@ -1443,6 +1451,12 @@ Union types have the potential to be invalid if incorrectly defined.
1443
1451
2. The member types of a Union type must all be Object , Interface or Union
1444
1452
types ; Scalar and Enum types must not be member types of a Union . Similarly ,
1445
1453
wrapping types must not be member types of a Union .
1454
+ 3. A parent Union must explicitly include as member types of all child Union
1455
+ members .
1456
+ 1. Let this union type be {unionType }.
1457
+ 2. For each {memberType } declared as a member of {unionType }, if {memberType }
1458
+ is a Union type , all of the members of {memberType } must also be members
1459
+ of {unionType }.
1446
1460
1447
1461
### Union Extensions
1448
1462
@@ -1469,6 +1483,12 @@ Union type extensions have the potential to be invalid if incorrectly defined.
1469
1483
the original Union type .
1470
1484
5. Any non -repeatable directives provided must not already apply to the original
1471
1485
Union type .
1486
+ 6. A parent Union must explicitly include as member types of all child Union
1487
+ members .
1488
+ 1. Let this union type be {unionType }.
1489
+ 2. For each {memberType } declared as a member of {unionType }, if {memberType }
1490
+ is a Union type , all of the members of {memberType } must also be members
1491
+ of {unionType }.
1472
1492
1473
1493
## Enums
1474
1494
0 commit comments