Skip to content

Instantly share code, notes, and snippets.

Avatar
✂️
Yak Shaving

Tatsuya Itakura itkrt2y

✂️
Yak Shaving
View GitHub Profile
@itkrt2y
itkrt2y / page.rb
Last active Aug 1, 2022 — forked from rmosolgo/page_example.rb
Generic page number / per-page pagination with GraphQL-Ruby
View page.rb
class Page
DEFAULT_PAGE_SIZE = 20
def initialize(all_nodes, page:, per_page:)
@all_nodes = all_nodes
# Normalize pagination arguments
@page = if page.nil? || page < 1
1
else
page