allow unions to declare implementation of interfaces
At a glance​
- Identifier: #939
- Stage: RFC1: Proposal
- Champion: @yaacovCR
- PR: allow unions to declare implementation of interfaces
- Related:
- #373 (Allow interfaces to implement other interfaces)
- ExpandingSubtyping (Expanding Subtyping (for output types))
- wg#944 (New Intersection Type)
Timeline​
- Added to 2022-06-02 WG agenda
- Mentioned in 2022-06-02 WG notes
- Commit pushed: unions implementing interfaces have fields on 2022-05-23 by @yaacovCR
- Added to 2022-04-07 WG agenda
- Mentioned in 2022-04-07 WG notes
- 2 commits pushed on 2022-04-06:
- Spec PR created on 2022-04-05 by yaacovCR
- Commit pushed: Add spec text for unions implementing interfaces on 2022-04-05 by @yaacovCR
Cf. https://github.com/graphql/graphql-spec/pull/373#issuecomment-375489730
# generic types
interface Node {
id: ID!
}
interface Connection {
pageInfo: PageInfo!
edges: [Edge]
}
interface Edge {
cursor: String
node: Node
}
type PageInfo {
hasPreviousPage: Boolean
hasNextPage: Boolean
startCursor: String
endCursor: String
}
# schema-specific types
interface Pet {
id: ID!
name: String
}
type Cat implements Pet & Node {
id: ID!
name: String
}
type Dog implements Pet & Node {
id: ID!
name: String
}
union HousePet implements Pet & Node = Cat | Dog
# house-pet-specific types
type HousePetEdge implements Edge {
cursor: String
node: HousePet # <<< This is what is unlocked by this PR
}
type HousePetConnection implements Connection {
pageInfo: PageInfo!
edges: [HousePetEdge]
}
# query
type Query {
housePets: HousePetConnection
}