{"id":13879638,"url":"https://github.com/bitjourney/graphql-autotest","last_synced_at":"2025-07-16T15:32:38.945Z","repository":{"id":45486118,"uuid":"247289948","full_name":"bitjourney/graphql-autotest","owner":"bitjourney","description":"GraphQL::Autotest tests GraphQL API with auto-generated queries.","archived":false,"fork":false,"pushed_at":"2024-01-14T07:13:01.000Z","size":63,"stargazers_count":42,"open_issues_count":1,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-11T13:42:46.029Z","etag":null,"topics":[],"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/bitjourney.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2020-03-14T14:17:36.000Z","updated_at":"2024-10-17T13:25:28.000Z","dependencies_parsed_at":"2023-12-28T07:43:52.775Z","dependency_job_id":null,"html_url":"https://github.com/bitjourney/graphql-autotest","commit_stats":{"total_commits":43,"total_committers":3,"mean_commits":"14.333333333333334","dds":0.06976744186046513,"last_synced_commit":"919f599468c3fb706433dd4007b899321c617a2b"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitjourney%2Fgraphql-autotest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitjourney%2Fgraphql-autotest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitjourney%2Fgraphql-autotest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitjourney%2Fgraphql-autotest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitjourney","download_url":"https://codeload.github.com/bitjourney/graphql-autotest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226143895,"owners_count":17580245,"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:02:27.445Z","updated_at":"2024-11-24T08:31:33.052Z","avatar_url":"https://github.com/bitjourney.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# GraphQL::Autotest\n\nGraphQL::Autotest tests your GraphQL API with auto-generated queries.\n\n## Requirements\n\nGraphQL::Autotest only supports Ruby 3.0 or higher\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'graphql-autotest'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install graphql-autotest\n\n## Usage\n\n### Generate queries and execute them\n\n```ruby\nrequire 'graphql/autotest'\n\nclass YourSchema \u003c GraphQL::Schema\nend\n\nrunner = GraphQL::Autotest::Runner.new(\n  schema: YourSchema,\n  # The context that is passed to GraphQL::Schema.execute\n  context: { current_user: User.first },\n)\n\n# * Generate queries from YourSchema\n# * Then execute the queries\n# * Raise an error if the results contain error(s)\nrunner.report!\n```\n\n### Generate queries from `GraphQL::Schema` (not execute)\n\n```ruby\nrequire 'graphql/autotest'\n\nclass YourSchema \u003c GraphQL::Schema\nend\n\nfields = GraphQL::Autotest::QueryGenerator.generate(document: YourSchema.to_document)\n\n# Print all generated queries\nfields.each do |field|\n  puts field.to_query\nend\n```\n\n### Generate queries from file (not execute)\n\nIt is useful for non graphql-ruby user.\n\n```ruby\nrequire 'graphql/autotest'\n\nfields = GraphQL::Autotest::QueryGenerator.from_file(path: 'path/to/definition.graphql')\n\n# Print all generated queries\nfields.each do |field|\n  puts field.to_query\nend\n```\n\n### Configuration\n\n`GraphQL::Autotest::Runner.new`, `GraphQL::Autotest::QueryGenerator.generate` and `GraphQL::Autotest::QueryGenerator.from_file` receives the following arguments to configure how to generates queries.\n\n* `arguments_fetcher`\n  * A proc to fill arguments of the received field.\n  * default: `GraphQL::Autotest::ArgumentsFetcher::DEFAULT`, that allows empty arguments, and arguments that has no required argument.\n  * You need to specify the proc if you need to test field that has required arguments.\n* `max_depth`\n  * Max query depth.\n  * default: 10\n* `skip_if`\n  * A proc to specify field that you'd like to skip to generate query.\n  * default: skip nothing\n\nFor example:\n\n```ruby\nrequire 'graphql/autotest'\n\nclass YourSchema \u003c GraphQL::Schema\nend\n\n# Fill `first` argument to reduce result size.\nfill_first = proc do |field|\n  field.arguments.any? { |arg| arg.name == 'first' } \u0026\u0026 { first: 5 }\nend\n\n# Skip a sensitive field\nskip_if = proc do |field|\n  field.name == 'sensitiveField'\nend\n\nfields = GraphQL::Autotest::QueryGenerator.generate(\n  document: YourSchema.to_document,\n  arguments_fetcher: GraphQL::Autotest::ArgumentsFetcher.combine(\n    fill_first,\n    GraphQL::Autotest::ArgumentsFetcher::DEFAULT,\n  ),\n  max_depth: 5,\n  skip_if: skip_if,\n)\n\n# Print all generated queries\nfields.each do |field|\n  puts field.to_query\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. 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`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/bitjourney/graphql-autotest.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitjourney%2Fgraphql-autotest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitjourney%2Fgraphql-autotest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitjourney%2Fgraphql-autotest/lists"}