{"id":13879772,"url":"https://github.com/d12/graphql-remote_loader","last_synced_at":"2025-08-12T02:04:35.371Z","repository":{"id":56875269,"uuid":"136680657","full_name":"d12/graphql-remote_loader","owner":"d12","description":"Performant remote GraphQL queries from within the resolvers of a Ruby GraphQL API.","archived":false,"fork":false,"pushed_at":"2020-09-14T14:55:38.000Z","size":89,"stargazers_count":50,"open_issues_count":7,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-27T20:49:12.482Z","etag":null,"topics":["graphql","graphql-ruby","graphql-server","ruby","ruby-gem","schema-stitching"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d12.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-09T01:28:36.000Z","updated_at":"2025-04-23T14:03:14.000Z","dependencies_parsed_at":"2022-08-20T22:00:39.641Z","dependency_job_id":null,"html_url":"https://github.com/d12/graphql-remote_loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/d12/graphql-remote_loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d12%2Fgraphql-remote_loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d12%2Fgraphql-remote_loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d12%2Fgraphql-remote_loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d12%2Fgraphql-remote_loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d12","download_url":"https://codeload.github.com/d12/graphql-remote_loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d12%2Fgraphql-remote_loader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269987123,"owners_count":24508176,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["graphql","graphql-ruby","graphql-server","ruby","ruby-gem","schema-stitching"],"created_at":"2024-08-06T08:02:32.447Z","updated_at":"2025-08-12T02:04:35.340Z","avatar_url":"https://github.com/d12.png","language":"Ruby","readme":"# GraphQL Remote Loader\n[![Gem Version](https://badge.fury.io/rb/graphql-remote_loader.svg)](https://badge.fury.io/rb/graphql-remote_loader) [![Build Status](https://travis-ci.org/d12/graphql-remote_loader.svg?branch=master)](https://travis-ci.org/d12/graphql-remote_loader)\n\nPerformant, batched GraphQL queries from within the resolvers of a [`graphql-ruby`](https://github.com/rmosolgo/graphql-ruby) API.\n\n\n## Snippet\n\n```ruby\nfield :login, String, null: false, description: \"The currently authenticated GitHub user's login.\"\n\ndef login\n  GitHubLoader.load(\"viewer { login }\").then do |results|\n    if results[\"errors\"].present?\n      \"\"\n    else\n      results[\"data\"][\"viewer\"][\"login\"].upcase\n    end\n  end\nend\n```\n\n## Description\n`graphql-remote_loader` allows for querying GraphQL APIs from within resolvers of a [`graphql-ruby`](https://github.com/rmosolgo/graphql-ruby) API. \n\nThis can be used to create GraphQL APIs that depend on data from other GraphQL APIs, either remote or local.\n\nA promise-based resolution strategy from Shopify's [`graphql-batch`](https://github.com/Shopify/graphql-batch) is used to batch all requested data into a single GraphQL query. Promises are fulfilled with only the data they requested.\n\nYou can think of it as a lightweight version of schema-stitching.\n\n## Performance\n\nEach `Loader#load` invocation does not send a GraphQL query to the remote. The Gem uses graphql-batch to collect all GraphQL queries together, then combines them and sends a single query to the upstream. The gem splits the response JSON up so that each promise is only resolved with data that it asked for.\n\n## How to use\nFirst, you'll need to install the gem. Either do `gem install graphql-remote_loader` or add this to your Gemfile:\n\n```\ngem \"graphql-remote_loader\"\n```\n\nThe gem provides a base loader `GraphQL::RemoteLoader::Loader` which does most of the heavy lifting. In order to remain client-agnostic, there's an unimplemented no-op that takes a query string and queries the remote GraphQL API.\n\nTo use, create a new class that inherits from `GraphQL::RemoteLoader::Loader` and define `def query(query_string)`. The method takes a query String as input. The expected output is a response `Hash`, or an object that responds to `#to_h`.\n\nExample:\n\n```ruby\nrequire \"graphql/remote_loader\"\n\nmodule MyApp\n  class GitHubLoader \u003c GraphQL::RemoteLoader::Loader\n    def query(query_string)\n      parsed_query = GraphQLClient.parse(query_string)\n      GraphQLClient.query(parsed_query)\n    end\n  end\nend\n```\n\nThis example uses [`graphql-client`](https://github.com/github/graphql-client). Any client, or even just plain `cURL`/`HTTP` can be used.\n\nWith your loader setup, you can begin using `#load` or `#load_value` in your `graphql-ruby` resolvers.\n\n## Full example\n\nTo see a working example of how `graphql-remote_loader` works, see the [complete, working example application](https://github.com/d12/graphql-remote_loader_example).\n\n## Running tests\n\n```\nbundle install\nbundle exec rspec\n```\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd12%2Fgraphql-remote_loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd12%2Fgraphql-remote_loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd12%2Fgraphql-remote_loader/lists"}