Skip to main content

allow unions to declare implementation of interfaces

At a glance

Timeline


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
}