{"id":22105051,"url":"https://github.com/tilotech/batch-graphql","last_synced_at":"2025-10-08T21:43:39.045Z","repository":{"id":65581021,"uuid":"593230831","full_name":"tilotech/batch-graphql","owner":"tilotech","description":"Fast batch queries against GraphQL APIs.","archived":false,"fork":false,"pushed_at":"2023-01-30T13:55:21.000Z","size":39,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-25T06:29:27.100Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/tilotech.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":"2023-01-25T14:41:51.000Z","updated_at":"2023-12-29T17:59:42.000Z","dependencies_parsed_at":"2023-02-16T07:46:06.088Z","dependency_job_id":null,"html_url":"https://github.com/tilotech/batch-graphql","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.08333333333333337,"last_synced_commit":"ebf1ebb2302a4afc3407239a4f1ce0573bcf8fc1"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tilotech/batch-graphql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilotech%2Fbatch-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilotech%2Fbatch-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilotech%2Fbatch-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilotech%2Fbatch-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tilotech","download_url":"https://codeload.github.com/tilotech/batch-graphql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilotech%2Fbatch-graphql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000703,"owners_count":26082837,"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-10-08T02:00:06.501Z","response_time":56,"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":[],"created_at":"2024-12-01T06:37:50.802Z","updated_at":"2025-10-08T21:43:39.012Z","avatar_url":"https://github.com/tilotech.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# batch-graphql\n\nbatch-graphql is a CLI tool for easily sending batch requests to an GraphQL API\nusing the same query or mutation with varying variables. It is made for highly\nconcurrent requests to fully utilize the capacity of your and the servers\nnetwork resources.\n\n## Installation\n\nEither download one of the [binary releases](releases) or install from\nsource:\n\n```\ngo install github.com/tilotech/batch-graphql\n```\n\n## Usage\n\nAssuming there is a public GraphQL service under https://example.com/graphql\nthen this would be a minimal request:\n\n```\nbatch-graphql -q path/to/query.graphql -i path/to/variables.jsonl -u https://example.com\n```\n\nFor a more realistic example we're going to use the GraphQL API from Github. As\nthe API requires authorization, we're assuming that you have a\n[personal access token (classic)](https://github.com/settings/tokens) available\nthat has at least the `read:user` scope.\n\nFirst we need a file with the GraphQL query and with the request variables:\n\nquery.graphql:\n```\nquery UserCompanyName ($loginName: String!) {\n\tuser(login: $loginName) {\n\t\tcompany\n\t}\n}\n```\n\nvariables.jsonl:\n```\n{\"loginName\": \"stefan-berkner-tilotech\"}\n{\"loginName\": \"sami-yaseen-tilotech\"}\n```\n\nThe query will provide us with the company names for the specified users.\n\nNow you can set the access token via the `--token` flag or via a configuration\nfile, but the preferred way is to set it using environment variables:\n\n```\nexport BATCH_GRAPHQL_TOKEN=your-access-token\n```\n\nThat's all that is needed to run queries against the Github GraphQL API:\n\n```\ngo run main.go -q query.graphql -i variables.jsonl -u https://api.github.com/graphql\n```\n\n## Configuration\n\n`batch-graphql` can be configured using flags, configuration files or\nenvironment variables or any mix of those.\n\nFor a full list of supported configuration options run\n\n```\nbatch-graphql help\n```\n\nBy default the configuration file is located under `$HOME/.batch-graphql.json`.\nOther file types (e.g. `yaml`) are also supported. You can change the location\nof the configuration file by providing the `--config` flag.\n\nEnvironment variables must be prefixed with `BATCH_GRAPHQL_` and then the flag\nname, e.g. `BATCH_GRAPHQL_CONNECTIONS` or `BATCH_GRAPHQL_OAUTH_URL`.\n\n### Increasing Parallel Requests\n\nUsing the `--connections` flag (`BATCH_GRAPHQL_CONNECTIONS` environment\nvariable), you can increase the number of parallel requests performed. By\ndefault only lame `10` requests are send in parallel, but depending on your computer,\nthe network connection and the server, a value between `100` and `300` (or even\nmore) should also be possible.\n\n### Authorization and Custom Headers\n\n`batch-graphql` supports three variants of providing authorization against the\nGraphQL API: (static) bearer tokens, OAuth 2.0 client credentials flow and\ncustom authorization using custom HTTP headers.\n\n#### Static Bearer Token\n\nAPIs like Github support a bearer token, which can be set via the `--token` flag\n(`BATCH_GRAPHQL_TOKEN` environment variable). This token will not change during\nthe whole batch operation.\n\n#### OAuth 2.0 Credentials Flow\n\nFor APIs that support the OAuth 2.0 client credentials flow, you can use the\n`oauth` flags:\n\n* `--oauth.url` (`BATCH_GRAPHQL_OAUTH_URL`)\n* `--oauth.clientid` (`BATCH_GRAPHQL_OAUTH_CLIENTID`)\n* `--oauth.clientsecret` (`BATCH_GRAPHQL_OAUTH_CLIENTSECRET`)\n* `--oauth.scope` (`BATCH_GRAPHQL_OAUTH_SCOPE`)\n\nOr as a configuration file:\n\n```\n{\n  \"oauth\": {\n    \"url\": \"\u003clogin url\u003e\",\n    \"clientid\": \"\u003cclient id\u003e\",\n    \"clientsecret\": \"\u003cclient secret\u003e\",\n    \"scope\": \"\u003cscope(s)\u003e\"\n  }\n}\n```\n\nUsing the client credentials flow, will request a bearer token from the provided\nURL and use that for consecutive calls. Before the token expires, it will\nautomatically request a new token.\n\n#### Custom Header\n\nIf neither of that fits, it is also possible to set custom headers:\n\n```\nbatch-graphql ... --header \"Authorization: value\" --header \"X-XYZ: foobar\"\n```\n\nOr as a configuration file:\n\n```\n{\n  \"headers\": [\n    \"Authorization: value\",\n    \"X-XYZ: foobar\"\n  ]\n}\n```\n\n### Input and Output\n\nThe input for `batch-graphql` must be a stream of JSON objects, typically a\nJSON line file. You can provide the input either via the `--input` flag\n(`BATCH_GRAPHQL_INPUT`) or via `stdin`.\n\nThe output will be in JSON line, where each JSON object contains the original\ninput, a row number, the (parsed) output as it was returned from the GraphQL\nAPI and an `null` error. By default the output will be written to `stdout`, but\ncan be changed to any file using the `--output` flag (`BATCH_GRAPHQL_OUTPUT`).\n\nIf an error occurs, the error will be written either to `stderr` or to a file\nprovided with the `--error` flag (`BATCH_GRAPHQL_ERROR`). The format is the same\nas for the regular output, except, that only the `error` message is guaranteed\nto be filled and everything else is optional.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftilotech%2Fbatch-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftilotech%2Fbatch-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftilotech%2Fbatch-graphql/lists"}