Skip to content

Commit

Permalink
add requirement that implementions of interfaces included by unions m…
Browse files Browse the repository at this point in the history
…ust be explicitly listed within the union
  • Loading branch information
yaacovCR committed Jul 28, 2022
1 parent 2a4d3ed commit 31e592e
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions spec/Section 3 -- Type System.md
Original file line number Diff line number Diff line change
Expand Up @@ -1373,18 +1373,20 @@ union SearchResult =
**Unions of Interfaces and Unions**

A Union may declare interfaces or other unions as member types. Transitively
included object types (object types included within a union included by a union)
must also be included within the parent union. For example, the following types
are valid:
included types must also be included within the parent union. If a parent union
includes a child union, all types included by the child union must be included
by the parent union. Similarly, if a union includes an interface, all types
implementing the interface must be included by the union. For example, the
following types are valid:

```graphql example
union SearchResult = Item | Photo | Video | Named
union SearchResult = Item | Photo | Video | Named | Person

interface Named {
name: String
}

type Person {
type Person implements Named {
name: String
age: Int
}
Expand Down Expand Up @@ -1426,11 +1428,18 @@ And, given the above, the following operation is valid:
}
```

While the following union is invalid, because the member types of `Item` are not
explicitly included within `SearchResult`:
While the following union is invalid, because `Photo` and `Video` are contained
by the union `Item` and are not explicitly included within `SearchResult`:

```graphql counter-example
union SearchResult = Item | Named
union SearchResult = Item | Named | Person
```

The following union is also invalid, because `Person` implements `Named`, but is
not explicitly included within `SearchResult`:

```graphql counter-example
union SearchResult = Item | Photo | Video | Named
```

**Result Coercion**
Expand Down

0 comments on commit 31e592e

Please sign in to comment.