{"id":13879795,"url":"https://github.com/nettofarah/graphql-query-resolver","last_synced_at":"2025-04-14T22:36:53.308Z","repository":{"id":71650277,"uuid":"84883982","full_name":"nettofarah/graphql-query-resolver","owner":"nettofarah","description":"Minimize N+1 queries generated by GraphQL and ActiveRecord","archived":false,"fork":false,"pushed_at":"2018-04-26T06:04:20.000Z","size":28,"stargazers_count":147,"open_issues_count":4,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-28T10:50:18.733Z","etag":null,"topics":["activerecord","graphql","graphql-ruby","rails"],"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/nettofarah.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2017-03-13T23:23:24.000Z","updated_at":"2025-01-09T12:14:08.000Z","dependencies_parsed_at":"2023-02-22T00:45:13.509Z","dependency_job_id":null,"html_url":"https://github.com/nettofarah/graphql-query-resolver","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nettofarah%2Fgraphql-query-resolver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nettofarah%2Fgraphql-query-resolver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nettofarah%2Fgraphql-query-resolver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nettofarah%2Fgraphql-query-resolver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nettofarah","download_url":"https://codeload.github.com/nettofarah/graphql-query-resolver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248974655,"owners_count":21192186,"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","graphql","graphql-ruby","rails"],"created_at":"2024-08-06T08:02:33.548Z","updated_at":"2025-04-14T22:36:53.282Z","avatar_url":"https://github.com/nettofarah.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# GraphQL::QueryResolver\n[![Build Status](https://travis-ci.org/nettofarah/graphql-query-resolver.svg?branch=master)](https://travis-ci.org/nettofarah/graphql-query-resolver)\n\nGraphQL::QueryResolver is an add-on to [graphql-ruby](https://github.com/rmosolgo/graphql-ruby)\nthat allows your field resolvers to minimize N+1 SELECTS issued by ActiveRecord.\n\nGraphQL::QueryResolver will analyze the AST from incoming GraphQL queries and\ntry to match query selections to `ActiveRecord::Reflections` present in your\n`ActiveRecord` models.\n\nEvery matched selection will be then passed on to\n`ActiveRecord::Associations::Preloader.new` so your queries now only issue\none `SELECT` statement for every level of the GraphQL AST.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'graphql-query-resolver'\n```\n\nAnd then execute:\n```bash\n$ bundle\n```\n\nOr install it yourself as:\n```bash\n$ gem install graphql-query-resolver\n```\n\n## Usage\n```ruby\nrequire 'graphql/query_resolver'\n\n# In your field resolver\n# Assuming `Project \u003c ActiveRecord::Base` and a `ProjectType` GraphQL type:\n#\nfield :projects do\n  type types[ProjectType]\n\n  resolve -\u003e (obj, args, ctx) {\n    # Wrap your field resolve operation with `GraphQL::QueryResolver`\n    GraphQL::QueryResolver.run(Project, ctx, ProjectType) do\n      Project.all\n    end\n  }\nend\n\n# QueryResolver works the same way for single objects\n\nfield :comment do\n  type CommentType\n  argument :id, !types.ID\n\n  resolve -\u003e (obj, args, ctx) {\n    GraphQL::QueryResolver.run(Comment, ctx, CommentType) do\n      Comment.find(args['id'])\n    end\n  }\nend\n```\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`.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/nettofarah/graphql-query-resolver. 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\nTo run the specs across all supported versions of ActiveRecord, check out the repo and follow these steps:\n```bash\n$ bundle install\n$ bundle exec appraisal install\n$ bundle exec appraisal rake\n```\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnettofarah%2Fgraphql-query-resolver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnettofarah%2Fgraphql-query-resolver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnettofarah%2Fgraphql-query-resolver/lists"}