{"id":22486158,"url":"https://github.com/opentable/graphql-query-generator","last_synced_at":"2025-08-02T19:30:58.025Z","repository":{"id":40767683,"uuid":"87437748","full_name":"opentable/graphql-query-generator","owner":"opentable","description":"Generates queries from the GraphQL endpoint via schema introspection.","archived":true,"fork":false,"pushed_at":"2022-10-06T19:41:36.000Z","size":116,"stargazers_count":48,"open_issues_count":9,"forks_count":9,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-07-06T16:54:03.857Z","etag":null,"topics":["graphql","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/opentable.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":"2017-04-06T14:19:43.000Z","updated_at":"2023-04-17T08:50:14.000Z","dependencies_parsed_at":"2022-08-27T12:53:06.738Z","dependency_job_id":null,"html_url":"https://github.com/opentable/graphql-query-generator","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/opentable/graphql-query-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fgraphql-query-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fgraphql-query-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fgraphql-query-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fgraphql-query-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opentable","download_url":"https://codeload.github.com/opentable/graphql-query-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fgraphql-query-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268440225,"owners_count":24250753,"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-02T02:00:12.353Z","response_time":74,"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","testing-tools"],"created_at":"2024-12-06T17:13:59.412Z","updated_at":"2025-08-02T19:30:57.723Z","avatar_url":"https://github.com/opentable.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![build](https://api.travis-ci.org/opentable/graphql-query-generator.svg?branch=master)](https://travis-ci.org/opentable/graphql-query-generator)\n\n**This repo is no longer maintained**. Feel free to fork and enjoy it, but no further development is anticipated.\n\n# GraphQL Query Generator\nGraphQL Query Generator is a library/tool that helps you easily test your GraphQL endpoints using introspection!\n\n## Getting Started\nSo you want to test your GraphQL endpoint.  This tool will generate all the queries that your GraphQL endpoint will have.  However, for queries that require parameters, this tool will need annotations.  So please follow the steps below to get started.\n\n### 1. Annotate your queries (optional, although highly recommended):\nCreate example queries that you want tested in the comments!\n```graphql\ntype Query {\n  # RollDice has four examples\n  #\n  # Examples:\n  # rollDice(numDice: 4, numSides: 2)\n  # rollDice( numDice : 40 , numSides:2)\n  # rollDice ( numDice: 2, numSides: 299 )\n  # rollDice (\n  #   numDice:4,\n  #   numSides: 2342\n  # )\n  rollDice(numDice: Int!, numSides: Int): RandomDie\n}\n```\n\n### 2 Run the tool!\n\nYou can use either the CLI or the library to get started!\n\n#### 2.1 Using the CLI\n\nExecute following commands to get this tool running.\n\u003e NOTE: Whenever there are parameters required you need to provide them in Graphql schema by following our Examples notation. You can find it in [Usage](#1-annotate-your-queries-optional-although-highly-recommended) section.\n\n```\nnpm i -g graphql-query-generator\ngql-test http://\u003cyour-server-address\u003e:\u003cyour-server-port\u003e\ngql-test --help # for more information\n```\n\n#### 2.2 Using the library\nIf you want more control over the queries that are generated via this tool.  Please see the following example:\n\n```javascript\nconst QueryGenerator = require('graphql-query-generator');\nconst request = require('request');\nconst assert = require('assert');\n\ndescribe('Query generation', function() {\n  const serverUrl = 'http://\u003cyour-server-address\u003e:\u003cyour-server-port\u003e/graphql';\n  let queries = null;\n\n  before(() =\u003e {\n    const queryGenerator = new QueryGenerator(serverUrl);\n    queryPromise = queryGenerator.run();\n  });\n\n  it('Generates multiple queries', function() {\n    this.timeout = 50000;\n\n    return queryPromise\n      .then(({queries, coverage}) =\u003e{\n          console.log(`Coverage: ${coverage.coverageRatio}`);\n          console.log(`skipped fields: ${coverage.notCoveredFields}`);\n          return Promise.all(queries.map(query =\u003e requestToGraphQL(serverUrl, query)));\n      })\n      .then(results =\u003e assert.equal(results.filter(x =\u003e x.statusCode !== 200).length, 0));\n  });\n});\n\nfunction requestToGraphQL(serverUrl, query) {\n  return new Promise((resolve, reject) =\u003e {\n    request(serverUrl, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json'\n      },\n      body:JSON.stringify({\n        \"query\": query,\n        \"variables\": \"{}\",\n        \"operationName\": null\n      })\n    }, function (err, result) {\n      if (err) return reject(err);\n\n      resolve(result)\n    });\n  });\n}\n```\n\nThis is an example of a test that will just check that it returns HTTP status code 200!  It would be also good to check if, say, the body contains an error section.  However, it's all up to you!\n\n\n## Extras\n\n### Opt out of certain queries\n\nWhen annotating, if you add `+NOFOLLOW` in examples will prevent this path from being followed when creating queries\n\n```graphql\ntype RandomDie {\n  numSides: Int!\n  rollOnce: Int!\n  statistics(page: Int!): RandomnessStatistics!\n\n  # A description for ignored field with parameters\n  #\n  # Examples:\n  # ignoredWithExamples(parameter: 42)\n  # +NOFOLLOW\n  ignoredWithExamples(parameter: Int!): IgnoredSubtype\n\n  # +NOFOLLOW\n  ignoredNoParameters: IgnoredSubtype\n}\n```\n\n## Contributing\nWe welcome feedback!  Please create an issue for feedback or issues.  If you would like to contribute, open a PR and let's start talking!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fgraphql-query-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopentable%2Fgraphql-query-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fgraphql-query-generator/lists"}