Skip to content

Commit cd8502c

Browse files
committed
add motivation within the example
1 parent 54db84a commit cd8502c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

spec/Section 3 -- Type System.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -1450,12 +1450,20 @@ inline fragments (with the exception of the meta-field {\_\_typename}).
14501450
For example, we might define the following types:
14511451

14521452
```graphql example
1453-
union SearchResult = Photo | Person
1453+
interface Link {
1454+
link: Downloadable
1455+
}
14541456

1455-
interface Downloadable = {
1456-
url: String
1457+
type SearchResultLink implements Link {
1458+
link: DownloadableSearchResult
1459+
}
1460+
1461+
interface Downloadable {
1462+
url: string
14571463
}
14581464

1465+
union SearchResult = Photo | Person
1466+
14591467
intersection DownloadableSearchResult = SearchResult & Downloadable
14601468

14611469
type Person implements Downloadable {
@@ -1475,6 +1483,11 @@ type SearchQuery {
14751483
}
14761484
```
14771485

1486+
Because intersection `DownloadableSearchResult` includes interface
1487+
`Downloadable` as a constraining member type, the possible types of the
1488+
intersection implement the `Downloadable` interface. The `link` field within
1489+
`SearchResultLink` therefore implements the `link` field of interface `Link`.
1490+
14781491
Just as with unions, the below could be ambiguous and is invalid.
14791492

14801493
```graphql counter-example

0 commit comments

Comments
 (0)