{"id":13879265,"url":"https://github.com/RenoFi/graphql-pagination","last_synced_at":"2025-07-16T15:31:51.269Z","repository":{"id":34867071,"uuid":"185547404","full_name":"RenoFi/graphql-pagination","owner":"RenoFi","description":"Page-based pagination for graphql-ruby","archived":false,"fork":false,"pushed_at":"2024-11-22T10:41:07.000Z","size":254,"stargazers_count":74,"open_issues_count":3,"forks_count":15,"subscribers_count":18,"default_branch":"main","last_synced_at":"2024-11-22T11:26:59.636Z","etag":null,"topics":["backend"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RenoFi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-08T06:41:23.000Z","updated_at":"2024-11-22T10:41:11.000Z","dependencies_parsed_at":"2024-01-10T16:36:38.047Z","dependency_job_id":"fc40a10f-3da9-46a0-bd6f-b539ab010727","html_url":"https://github.com/RenoFi/graphql-pagination","commit_stats":{"total_commits":218,"total_committers":10,"mean_commits":21.8,"dds":0.3302752293577982,"last_synced_commit":"ecf9002bc22c248855855fc69e80513f2e5cfd15"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RenoFi%2Fgraphql-pagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RenoFi%2Fgraphql-pagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RenoFi%2Fgraphql-pagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RenoFi%2Fgraphql-pagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RenoFi","download_url":"https://codeload.github.com/RenoFi/graphql-pagination/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226143895,"owners_count":17580245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend"],"created_at":"2024-08-06T08:02:15.675Z","updated_at":"2024-11-24T08:31:07.788Z","avatar_url":"https://github.com/RenoFi.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/graphql-pagination.svg)](https://rubygems.org/gems/graphql-pagination)\n[![Build Status](https://github.com/RenoFi/graphql-pagination/actions/workflows/ci.yml/badge.svg)](https://github.com/RenoFi/graphql-pagination/actions/workflows/ci.yml?query=branch%3Amain)\n\n# graphql-pagination\n\nImplements page-based pagination returning collection and pagination metadata. It works with `kaminari` or other pagination tools implementing similar methods.\n\n## Installation\n\nAdd `graphql-pagination` to your Gemfile, you can use `kaminari-activerecord` or `kaminari-monogid` to not implement page scope methods. Kaminari is not loaded by the gem, so you need to decide and load it on your own.\n\n```ruby\n  gem 'graphql-pagination'\n  gem 'kaminari-activerecord'\n```\n\n## Usage example\n\nUse `collection_type` instead of `connection_type` to define your type:\n\n```ruby\n  field :fruits, Types::FruitType.collection_type, null: true do\n    argument :page, Integer, required: false\n    argument :limit, Integer, required: false\n  end\n\n  def fruits(page: nil, limit: nil)\n    ::Fruit.page(page).per(limit)\n  end\n```\n\nValue returned by query resolver must be a kaminari object or implements its page scope methods (`current_page`, `limit_value`, `total_count`, `total_pages`).\n\n## GraphQL query\n\n```graphql\n{\n  fruits(page: 2, limit: 2) {\n    collection {\n      id\n      name\n    }\n    metadata {\n      totalPages\n      totalCount\n      currentPage\n      limitValue\n    }\n  }\n}\n```\n\n```json\n{\n  \"data\": {\n    \"checklists\": {\n      \"collection\": [\n        {\n          \"id\": \"93938bb3-7a6c-4d35-9961-cbb2d4c9e9ac\",\n          \"name\": \"Apple\"\n        },\n        {\n          \"id\": \"b1ee93b2-579a-4107-8454-119bba5afb63\",\n          \"name\": \"Mango\"\n        }\n      ],\n      \"metadata\": {\n        \"totalPages\": 25,\n        \"totalCount\": 50,\n        \"currentPage\": 2,\n        \"limitValue\": 2\n      }\n    }\n  }\n}\n```\n\n## Custom Base\n\nBy default the resulting collection_type class is a direct descendant of\ngraphql-ruby's GraphQL::Schema::Object, however you may require your own\nbehaviours and properties on the collection class itself such as defining\n[custom visibility](https://graphql-ruby.org/authorization/visibility.html#object-visibility).\n\nThis can be done by passing in your own custom class, to be inherited from:\n\n```ruby\nclass MyBaseType \u003c GraphQL::Schema::Object\n  def self.visible?(context)\n    # ...\n  end\nend\n\nfield :fruits, Types::FruitType.collection_type(collection_base: MyBaseType)\n```\n\n## Custom Metadata\n\nBy default, the following fields are present in the metadata block:\n\n```graphql\nmetadata {\n  totalPages\n  totalCount\n  currentPage\n  limitValue\n}\n```\n\nThese fields correspond to the `GraphqlPagination::CollectionMetadataType` used to provide the pagination information for the collection of data delivered. If you want to add more metadata fields to this block, you can do so by extending this `CollectionMetadataType`:\n\n```ruby\nclass MyMetadataType \u003c GraphqlPagination::CollectionMetadataType\n  field :custom_field, String, null: false\nend\n\nfield :fruits, Types::FruitType.collection_type(metadata_type: MyMetadataType)\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/renofi/graphql-pagination. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRenoFi%2Fgraphql-pagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRenoFi%2Fgraphql-pagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRenoFi%2Fgraphql-pagination/lists"}