{"id":13878298,"url":"https://github.com/dropbox/graphql-dataloader-activerecord","last_synced_at":"2025-07-16T14:31:48.322Z","repository":{"id":66208698,"uuid":"580205685","full_name":"dropbox/graphql-dataloader-activerecord","owner":"dropbox","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-31T01:17:49.000Z","size":22,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-10T03:09:49.385Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dropbox.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":"2022-12-20T01:18:09.000Z","updated_at":"2025-05-01T01:28:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"3dd55ae5-f693-4aed-8b9e-24e46a8754e7","html_url":"https://github.com/dropbox/graphql-dataloader-activerecord","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"fe36a2920f316d9822c011e9e9eb7d4ae0e3b914"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dropbox/graphql-dataloader-activerecord","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fgraphql-dataloader-activerecord","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fgraphql-dataloader-activerecord/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fgraphql-dataloader-activerecord/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fgraphql-dataloader-activerecord/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dropbox","download_url":"https://codeload.github.com/dropbox/graphql-dataloader-activerecord/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fgraphql-dataloader-activerecord/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264719238,"owners_count":23653541,"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":[],"created_at":"2024-08-06T08:01:45.578Z","updated_at":"2025-07-16T14:31:48.309Z","avatar_url":"https://github.com/dropbox.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# graphql-dataloader-activerecord\n\nThis gem provides proxy objects in place of ActiveRecord objects where the\nproxy handles relationship loading through GraphQL::Dataloader. This is an\nexperimental approach which should theoretically allow authors to write GraphQL\ncode that relies on ActiveRecord using regular ActiveRecord relationship\nmethods without generating N+1 query situations.\n\n## Usage\n\nBy including DataloaderRelationProxy::Lazy, your ActiveRecord-based type\nclasses can transparently use efficient Dataloaders. For example, in the\nfollowing example, N stories, and their authors can be authorized and loaded in\na constant number of queries without changing the implementation of the types:\n\n```ruby\nclass Query \u003c GraphQL::Schema::Object\n  field :stories, ['Types::Story']\n\n  def stories\n    ::Story.all\n  end\nend\n\nclass Story \u003c GraphQL::Schema::Object\n  include DataloaderRelationProxy::Lazy\n\n  field :author, Types::User\n  field :text, String\n\n  def self.authorized?(object, context)\n    # Even though it looks like we're loading the author here, object.author is\n    # actually spawning a new fiber and yielding back to the GraphQL engine.\n    # The return value is also chainable so we can continue to efficiently follow\n    # ActiveRecord relationships as shown:\n    return false unless object.author.plan.name == 'paid'\n\n    # Arbitrary rule to force publication to load to demonstrate this\n    # functionality\n    return object.publication.present?\n  end\n\n  # There is no need to define an `author` method here since @object responds\n  # to `author` already, but if we did, it would be:\n  def author\n    @object.author\n  end\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run\n`rake spec` to run the tests. You can also run `bin/console` for an interactive\nprompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To\nrelease a new version, update the version number in `version.rb`, and then run\n`bundle exec rake release`, which will create a git tag for the version, push\ngit commits and the created tag, and push the `.gem` file to\n[rubygems.org](https://rubygems.org).\n\n## Contributing\n\nPlease begin by filling out the contributor form and asserting that\n\n\u003e The code I'm contributing is mine, and I have the right to license it. I'm\n\u003e granting you a license to distribute said code under the terms of this\n\u003e agreement. at this page: https://opensource.dropbox.com/cla/\n\nThen create a new pull request through the github interface\n\n## License\n\nCopyright (c) 2022 Dropbox, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed\nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\nCONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdropbox%2Fgraphql-dataloader-activerecord","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdropbox%2Fgraphql-dataloader-activerecord","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdropbox%2Fgraphql-dataloader-activerecord/lists"}