Skip to content

Instantly share code, notes, and snippets.

@jensen
Created May 6, 2020 22:25
Show Gist options
  • Save jensen/c832022e7a1cdd76d7310bdff01b500b to your computer and use it in GitHub Desktop.
Save jensen/c832022e7a1cdd76d7310bdff01b500b to your computer and use it in GitHub Desktop.
Song Container Relay Example
query SongsContainerQuery($count: Int!, $cursor: String) {
viewer {
...SongsContainer_viewer
}
}
fragment SongsContainer_viewer on Query {
id
songs(first: $count, after: $cursor)
@connection(key: "SongsContainer_songs", filters: []) {
edges {
cursor
node {
id
...SongItem_song
}
}
}
}
query SongItemQuery($id: ID!, $count: Int!, $cursor: String) {
song(id: $id) {
...SongItem_song @arguments(count: $count, cursor: $cursor)
}
}
fragment SongItem_song on Audio
@argumentDefinitions(
count: { type: "Int", defaultValue: 20 }
cursor: { type: "String", defaultValue: null }
) {
id
...CommentsContainer_song
# ...more pagination container other_song
}
query CommentsContainerQuery($id: ID!, $count: Int!, $cursor: String) {
song(id: $id) {
...CommentsContainer_song
}
}
fragment CommentsContainer_song on Audio {
id
comments(first: $count, after: $cursor)
@connection(key: "CommentsContainer_comments", filters: []) {
edges {
id
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment