@@ -1305,16 +1305,17 @@ UnionMemberTypes :
1305
1305
- = `|`? NamedType
1306
1306
1307
1307
GraphQL Unions represent an object that could be one of a list of GraphQL Object
1308
- types , but provides for no guaranteed fields between those types . They also
1309
- differ from interfaces in that Object types declare what interfaces they
1310
- implement , but are not aware of what unions contain them .
1308
+ types . They differ from interfaces in that Object types declare what interfaces
1309
+ they implement , but are not aware of what unions contain them .
1311
1310
1312
1311
With interfaces and objects , only those fields defined on the type can be
1313
1312
queried directly ; to query other fields on an interface , typed fragments must be
1314
- used . This is the same as for unions , but unions do not define any fields , so
1315
- **no ** fields may be queried on this type without the use of type refining
1316
- fragments or inline fragments (with the exception of the meta-field
1317
- {\_\_typename}).
1313
+ used . This is the same as for unions , but unions do not directly define any
1314
+ fields , so the only fields that may be queried on a Union are the meta -field
1315
+ {\_ \_typename } and the fields of the interfaces that the Union declares it
1316
+ implements (see
1317
+ [Unions Implementing Interfaces](#sec-Unions.Unions-Implementing-Interfaces)).
1318
+ Otherwise, type refining fragments or inline fragments must be used.
1318
1319
1319
1320
For example, we might define the following types :
1320
1321
@@ -1399,6 +1400,22 @@ type Photo implements Resource {
1399
1400
}
1400
1401
```
1401
1402
1403
+ The following query would then be valid :
1404
+
1405
+ ```graphql example
1406
+ {
1407
+ firstSearchResult {
1408
+ url
1409
+ ... on Article {
1410
+ title
1411
+ }
1412
+ ... on Photo {
1413
+ height
1414
+ }
1415
+ }
1416
+ }
1417
+ ```
1418
+
1402
1419
Transitively implemented interfaces (interfaces implemented by the interface
1403
1420
that is being implemented) must also be defined on the implementing union . For
1404
1421
example , `SearchResult ` cannot implement `Resource ` without also implementing
0 commit comments