{"id":13879422,"url":"https://github.com/evilmartians/graphql-connections","last_synced_at":"2025-10-25T00:30:47.828Z","repository":{"id":40304720,"uuid":"277174940","full_name":"evilmartians/graphql-connections","owner":"evilmartians","description":"Additional implementations of cursor-based paginations for GraphQL Ruby gem.","archived":false,"fork":false,"pushed_at":"2023-11-07T19:51:36.000Z","size":49,"stargazers_count":45,"open_issues_count":3,"forks_count":14,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-09-29T12:03:49.366Z","etag":null,"topics":["activerecord","chewy","gem","graphql","ruby"],"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/evilmartians.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2020-07-04T19:42:23.000Z","updated_at":"2024-06-03T09:59:20.000Z","dependencies_parsed_at":"2023-09-10T21:09:47.541Z","dependency_job_id":"fcba044a-97e0-41d3-a959-2b5f6359a495","html_url":"https://github.com/evilmartians/graphql-connections","commit_stats":{"total_commits":32,"total_committers":6,"mean_commits":5.333333333333333,"dds":0.46875,"last_synced_commit":"06bca86e7061d014867354bfc62a7ca8bc2e3cc7"},"previous_names":["bibendi/graphql-connections"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilmartians%2Fgraphql-connections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilmartians%2Fgraphql-connections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilmartians%2Fgraphql-connections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilmartians%2Fgraphql-connections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evilmartians","download_url":"https://codeload.github.com/evilmartians/graphql-connections/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219867388,"owners_count":16555891,"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":["activerecord","chewy","gem","graphql","ruby"],"created_at":"2024-08-06T08:02:20.597Z","updated_at":"2025-10-25T00:30:42.412Z","avatar_url":"https://github.com/evilmartians.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/graphql-connections.svg)](https://badge.fury.io/rb/graphql-connections)\n[![Build Status](https://travis-ci.org/bibendi/graphql-connections.svg?branch=master)](https://travis-ci.org/bibendi/graphql-connections)\n\n# GraphQL::Connections\n\nAdditional implementations of cursor-based paginations for [GraphQL Ruby](https://graphql-ruby.org/).\n\n\u003ca href=\"https://evilmartians.com/?utm_source=graphql-connections\"\u003e\n\u003cimg src=\"https://evilmartians.com/badges/sponsored-by-evil-martians.svg\" alt=\"Sponsored by Evil Martians\" width=\"236\" height=\"54\"\u003e\u003c/a\u003e\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"graphql-connections\"\n```\n\n## Usage\n\n### ActiveRecord\n\nImplements [Relay specification](https://relay.dev/graphql/connections.htm) for serving stable connections based on column values.\nIf objects are created or destroyed during pagination, the list of items won’t be disrupted.\n\nYou can use a stable connection wrapper on a specific field:\n\n```ruby\nfield :messages, Types::Message.connection_type, null: false\n\ndef messages\n  GraphQL::Connections::Stable.new(Message.all)\nend\n```\n\nRecords are sorted by model's primary key by default. You can change this behaviour by providing `primary_key` param:\n\n```ruby\nGraphQL::Connections::Stable.new(Message.all, primary_key: :created_at)\n```\n\nIn case when you want records to be sorted by more than one field (i.e., _keyset pagination_), you can use `keys` param:\n\n```ruby\nGraphQL::Connections::Stable.new(Message.all, keys: %w[name id])\n```\n\nWhen you pass only one key, a primary key will be added as a second one:\n\n```ruby\nGraphQL::Connections::Stable.new(Message.all, keys: [:name])\n```\n\n**NOTE:** Currently we support maximum two keys in the keyset.\n\nAlso, you can pass the `:desc` option to reverse the relation:\n\n```ruby\nGraphQL::Connections::Stable.new(Message.all, keys: %w[name id], desc: true)\n```\n\n```ruby\nGraphQL::Connections::Stable.new(Message.all, primary_key: :created_at, desc: true)\n```\n\nAlso, you can disable opaque cursors by setting `opaque_cursor` param:\n\n```ruby\nGraphQL::Connections::Stable.new(Message.all, opaque_cursor: false)\n```\n\nOr you can apply a stable connection to all Active Record relations returning by any field:\n\n```ruby\nclass ApplicationSchema \u003c GraphQL::Schema\n  connections.add(ActiveRecord::Relation, GraphQL::Connections::Stable)\nend\n```\n\n**NOTE:** Don't use stable connections for relations whose ordering is too complicated for cursor generation.\n\n### Elasticsearch via Chewy\n\nRegister connection for all Chewy requests:\n\n```ruby\nclass ApplicationSchema \u003c GraphQL::Schema\n  connections.add(Chewy::Search::Request, GraphQL::Connections::ChewyConnection)\nend\n```\n\nAnd define field like below:\n\n```ruby\nfield :messages, Types::Message.connection_type, null: false\n\ndef messages\n  CitiesIndex.query(match: {name: \"Moscow\"})\nend\n```\n\n**NOTE:** Using `first` and `last`arguments simultaneously is not supported yet.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/bibendi/graphql-connections.\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%2Fevilmartians%2Fgraphql-connections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevilmartians%2Fgraphql-connections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilmartians%2Fgraphql-connections/lists"}