Skip to content

Instantly share code, notes, and snippets.

@kabece
Last active December 3, 2021 06:57
Show Gist options
  • Save kabece/c3ebb1d03cf6e41a7650f1ae7508fba4 to your computer and use it in GitHub Desktop.
Save kabece/c3ebb1d03cf6e41a7650f1ae7508fba4 to your computer and use it in GitHub Desktop.
Implementing GraphQL pagination in gqlgen
type Message {
id: ID!
text: String
}
type MessagesConnection {
edges: [MessagesEdge!]!
pageInfo: PageInfo!
}
type MessagesEdge {
cursor: ID!
node: Message
}
type PageInfo {
startCursor: ID!
endCursor: ID!
hasNextPage: Boolean
}
type ChatRoom {
id: ID!
name: String
messagesConnection(first: Int = 20, after: ID): MessagesConnection
}
type Query {
chatRoom(id: ID!): ChatRoom!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment