Skip to content

Instantly share code, notes, and snippets.

@alloy
Last active September 4, 2019 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alloy/8bfb39c476092e9847790c1d22efe5ea to your computer and use it in GitHub Desktop.
Save alloy/8bfb39c476092e9847790c1d22efe5ea to your computer and use it in GitHub Desktop.
# This is just the base schema shared by the two options below.
type User {
name: String
friendships: FriendshipConnection
}
type Friendship {
establishedAt: String
withUser: User
}
type Query {
me: User
}
# include 0-base-schema.graphql
type FriendshipConnection {
edges: [FriendshipConnectionEdge]
}
type FriendshipConnectionEdge {
metadata: Friendship
node: User
cursor: String
}
# Query like:
query {
me {
friendships {
edges {
__typename # FriendshipConnectionEdge
cursor
metadata {
__typename # Friendship
establishedAt
}
node {
__typename # User
name
}
}
}
}
}
# include 0-base-schema.graphql
# Add edge fields, as per spec. These fields don’t make much sense
# when this type is used elsewhere outside of a connection.
extend type Friendship {
node: User
cursor: String
}
type FriendshipConnection {
edges: [Friendship]
}
# Query like:
query {
me {
friendships {
edges {
__typename # Friendship
cursor
establishedAt
node {
__typename # User
name
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment