Skip to content

Instantly share code, notes, and snippets.

View itkrt2y's full-sized avatar
✂️
Yak Shaving

Tatsuya Itakura itkrt2y

✂️
Yak Shaving
View GitHub Profile
@itkrt2y
itkrt2y / page.rb
Last active April 12, 2023 16:23 — forked from rmosolgo/page_example.rb
Generic page number / per-page pagination with GraphQL-Ruby
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