Skip to content

Instantly share code, notes, and snippets.

@slightlytyler
Last active October 11, 2017 17:15
Show Gist options
  • Save slightlytyler/be08f0d018a3658781039effa589a371 to your computer and use it in GitHub Desktop.
Save slightlytyler/be08f0d018a3658781039effa589a371 to your computer and use it in GitHub Desktop.
GraphQL intersection types?
schema {
query: Query
}
type Query {
namespaces: AllNamespacesConnection
users: AllUsersConnection
}
interface Node {
id: ID!
}
interface Edge {
cursor: String!
node: Node!
}
interface Connection {
edges: [Edge]!
pageInfo: PageInfo!
}
type User implements Namespace, Node {
id: ID!
name: String!
}
type AllUsersEdge implements Edge {
cursor: String!
node: User!
}
type AllUsersConnection implements Connection {
edges: [AllUsersEdge]!
pageInfo: PageInfo!
}
interface Namespace {
name: String!
}
# Right here is the problem.
# How do we allow for a namespace edge?
# Intersection types maybe?
# `node` field values would need to implement both `Node` and `Namespace` to be valid
# https://github.com/facebook/graphql/issues/48
type AllNamespacesEdge implements Edge {
cursor: String!
node: (Node + Namespace)!
}
type AllNamespacesConnection implements Connection {
edges: [AllNamespacesEdge]!
pageInfo: PageInfo!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment