introduce new Intersection type#3550
Conversation
✅ Deploy Preview for compassionate-pike-271cb3 ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
|
Hi @yaacovCR, I'm @github-actions bot happy to help you with this PR 👋 Supported commandsPlease post this commands in separate comments and only one per comment:
|
dcea440 to
16e050a
Compare
intersection "implementing" interface# 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 = Cat | Dog
intersection HousePetNode = HousePet & Pet & Node
# house-pet-specific types
type HousePetEdge implements Edge {
cursor: String
node: HousePetNode # <<< This is what is unlocked by this PR
}
type HousePetConnection implements Connection {
pageInfo: PageInfo!
edges: [HousePetEdge]
}
# query
type Query {
housePets: HousePetConnection
}intersection "implementing" interface AND narrowing unions# 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
}
type Fish implements Pet & Node {
id: ID!
name: String
}
type Lion implements Pet & Node {
id: ID!
name: String
}
union HousePet = Cat | Dog | Fish
union PetWithFur = Cat | Dog | Lion
intersection HousePetWithFurNode = HousePet & PetWithFur & Pet & Node
# house-pet-specific types
type HousePetWithFurEdge implements Edge {
cursor: String
node: HousePetWithFurNode # <<< This is what is unlocked by this PR
}
type HousePetWithFurNodeConnection implements Connection {
pageInfo: PageInfo!
edges: [HousePetWithFurEdge]
}
# query
type Query {
housePetsWithFur: HousePetWithFurNodeConnection
} |
|
spec PR: graphql/graphql-spec#941 |
|
discussion @ graphql/graphql-wg#944 |
d6696df to
8723cad
Compare
Intersections of unions and interfaces can be considered to "implement" their unions and interface members. A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection. Alternative to graphql#3527
|
Summary of discussion from WG https://github.com/graphql/graphql-wg/blob/main/agendas/2022/2022-05-05.md :
The action item will then be to move forward as possible with graphql/graphql-spec#939 . Immediate next steps is to refine the implementation at #3527 with further checking for all the necessary validation and test changes. |
Intersections of unions and interfaces can be considered to "implement" their unions and interface members.
A type with a field of type Intersection will satisfy an interface where the field defined in the interface is one of the member types of the intersection.
Alternative to #3527