@@ -923,8 +923,8 @@ IsValidImplementationFieldType(fieldType, implementedFieldType):
923923 3. Return {IsValidImplementationFieldType (itemType, implementedItemType)}.
9249243. If {fieldType } is the same type as {implementedFieldType } then return {true }.
9259254. If {fieldType } is an Object type and {implementedFieldType } is a Union type
926- and {fieldType } is a possible type of {implementedFieldType } then return
927- {true }.
926+ and {fieldType } is a possible type or member type of {implementedFieldType }
927+ then return {true }.
9289285. If {fieldType } is an Object or Interface type and {implementedFieldType } is
929929 an Interface type and {fieldType } declares it implements
930930 {implementedFieldType } then return {true }.
@@ -1302,8 +1302,8 @@ UnionMemberTypes :
13021302- = `|`? NamedType
13031303
13041304GraphQL Unions represent an object that could be one of a list of GraphQL Object
1305- types , but provides for no guaranteed fields between those types . They also
1306- differ from interfaces in that Object types declare what interfaces they
1305+ types , providing for no guaranteed fields between those types . They differ from
1306+ interfaces in that Object and Interface types declare what interfaces they
13071307implement , but are not aware of what unions contain them .
13081308
13091309With interfaces and objects , only those fields defined on the type can be
@@ -1370,6 +1370,61 @@ union SearchResult =
13701370 | Person
13711371```
13721372
1373+ **Unions of Interfaces and Unions **
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 :
1378+
1379+ ```graphql example
1380+ union SearchResult = Photo | Named
1381+
1382+ interface Named {
1383+ name : String
1384+ }
1385+
1386+ type Person {
1387+ name : String
1388+ age : Int
1389+ }
1390+
1391+ union Item = Photo | Video
1392+
1393+ type Photo {
1394+ height : Int
1395+ width : Int
1396+ }
1397+
1398+ type Video {
1399+ codec : String
1400+ }
1401+
1402+ type SearchQuery {
1403+ firstSearchResult : SearchResult
1404+ }
1405+ ```
1406+
1407+ And , given the above , the following operation is valid :
1408+
1409+ ```graphql example
1410+ {
1411+ firstSearchResult {
1412+ ... on Named {
1413+ name
1414+ }
1415+ ... on Person {
1416+ age
1417+ }
1418+ ... on Photo {
1419+ height
1420+ }
1421+ ... on Video {
1422+ codec
1423+ }
1424+ }
1425+ }
1426+ ```
1427+
13731428**Result Coercion **
13741429
13751430The union type should have some way of determining which object a given result
@@ -1385,8 +1440,8 @@ Unions are never valid inputs.
13851440Union types have the potential to be invalid if incorrectly defined .
13861441
138714421. A Union type must include one or more unique member types .
1388- 2. The member types of a Union type must all be Object base types ; Scalar ,
1389- Interface and Union types must not be member types of a Union . Similarly ,
1443+ 2. The member types of a Union type must all be Object , Interface or Union
1444+ types ; Scalar and Enum types must not be member types of a Union . Similarly ,
13901445 wrapping types must not be member types of a Union .
13911446
13921447### Union Extensions
@@ -1406,9 +1461,9 @@ another GraphQL service.
14061461Union type extensions have the potential to be invalid if incorrectly defined .
14071462
140814631. The named type must already be defined and must be a Union type .
1409- 2. The member types of a Union type extension must all be Object base types ;
1410- Scalar , Interface and Union types must not be member types of a Union .
1411- Similarly , wrapping types must not be member types of a Union .
1464+ 2. The member types of a Union type must all be Object , Interface or Union
1465+ types ; Scalar and Enum types must not be member types of a Union . Similarly ,
1466+ wrapping types must not be member types of a Union .
141214673. All member types of a Union type extension must be unique .
141314684. All member types of a Union type extension must not already be a member of
14141469 the original Union type .
0 commit comments