Skip to content

Instantly share code, notes, and snippets.

@jde
Created August 7, 2017 14:08
Show Gist options
  • Save jde/1ad67b506669ae48d79a078efa407768 to your computer and use it in GitHub Desktop.
Save jde/1ad67b506669ae48d79a078efa407768 to your computer and use it in GitHub Desktop.
Pagination Pseudocode
#####
# Interfaces describing the two kinds of cursor based paginated inputs
#####
interface TimePaginator {
Cursor Date.Time
}
interface SkipLimitPaginator {
Skip int
Limit int
}
#####
# Types to capture pagination input
#####
type TimePaginationInput {
Cursor Date.Time # Start before or after this timestamp depending on
Limit int # Limit the number of results to be returned.
Sort string # Default: CHRONOLOGICAL, accepts REVERSE_CHRONOLOGICAL
}
type SkipLimitPaginationInput {
Skip int # Start before or after this timestamp depending on
Limit int # Limit the number of results to be returned.
Sort string # Default: CHRONOLOGICAL, accepts REVERSE_CHRONOLOGICAL
}
#####
# Examples
#####
# Comment by articles will probably be a time based query since:
# comments are constantly coming in
# users are expecting the "next" comments
type CommentsByArticleInput {
TimePaginationInput
ArticleID int # Article to search on
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment