{"id":13762813,"url":"https://github.com/doyensec/GQLSpection","last_synced_at":"2025-05-10T15:31:58.639Z","repository":{"id":65248857,"uuid":"589037730","full_name":"doyensec/GQLSpection","owner":"doyensec","description":"GQLSpection - parses GraphQL introspection schema and generates possible queries","archived":false,"fork":false,"pushed_at":"2024-03-14T11:52:35.000Z","size":221,"stargazers_count":27,"open_issues_count":11,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-28T04:35:12.196Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/doyensec.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-14T21:16:36.000Z","updated_at":"2024-06-18T09:13:23.504Z","dependencies_parsed_at":"2024-02-01T21:59:11.052Z","dependency_job_id":"77097d3c-895e-461d-aa8e-fc6a884af935","html_url":"https://github.com/doyensec/GQLSpection","commit_stats":{"total_commits":64,"total_committers":2,"mean_commits":32.0,"dds":0.03125,"last_synced_commit":"b64a114630d3796352720cc55eda2cfc6aa3810e"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doyensec%2FGQLSpection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doyensec%2FGQLSpection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doyensec%2FGQLSpection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doyensec%2FGQLSpection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doyensec","download_url":"https://codeload.github.com/doyensec/GQLSpection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224151162,"owners_count":17264436,"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-03T14:00:58.084Z","updated_at":"2024-11-16T21:30:45.257Z","avatar_url":"https://github.com/doyensec.png","language":"Python","funding_links":[],"categories":["Weapons"],"sub_categories":["Tools"],"readme":"# GQLSpection\n\nCLI tool and Python 2.7+ compatible library for parsing GraphQL introspection query and automatic query generation.\n\n![License](https://img.shields.io/github/license/doyensec/gqlspection?style=for-the-badge)\n![Python Versions](https://img.shields.io/pypi/pyversions/gqlspection?style=for-the-badge)\n![Jython Version](https://img.shields.io/badge/Jython%20%28lib%20only%29-2.7.3-success?style=for-the-badge)\n\n\n![Main branch](https://img.shields.io/github/actions/workflow/status/doyensec/gqlspection/Release.yml?style=for-the-badge\u0026label=main%20branch)\n![Dev branch](https://img.shields.io/github/actions/workflow/status/doyensec/gqlspection/QA.yml?branch=dev\u0026style=for-the-badge\u0026label=dev%20branch)\n![Coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/doyensec/GQLSpection/coverage-badge/coverage.json\u0026style=for-the-badge)\n\n## Installation\n\nGQLSpection is available on PyPI (Python 2.7 and Python 3+ versions are supported).\n\nRegular installation:\n\n```bash\n$ pip install gqlspection[cli]\n```\n\n## Usage of the CLI tool\n\nLoad schema from file and print all query and mutation names in the schema:\n\n```bash\n$ gqlspection -f schema.json -l all\n```\n\nSend introspection query and generate queries \u0026 mutations for everything:\n\n```bash\n$ gqlspection -u https://.../graphql\n```\n\nGenerate a single query:\n\n```bash\n$ gqlspection -u https://.../graphql -q something\n```\n\nGenerate a number of mutations:\n\n```bash\n$ gqlspection -f schema.json -m one,two,three\n```\n\n### Full help\n\n```\n$ ./gqlspection -h\nUsage: gqlspection [OPTIONS]\n\nOptions:\n  -f, --file TEXT      File with the GraphQL schema (introspection JSON).\n  -u, --url TEXT       URL of the GraphQL endpoint with enabled introspection.\n\n  -l, --list TEXT      Parse GraphQL schema and list queries, mutations or\n                       both of them (valid values are: 'queries', 'mutations'\n                       or 'all').\n\n  -q, --query TEXT     Only print named queries (argument is a comma-separated\n                       list of query names).\n\n  -m, --mutation TEXT  Only print named mutations (argument is a comma-\n                       separated list of mutation names).\n\n  -Q, --all-queries    Only print queries (by default both queries and\n                       mutations are printed).\n\n  -M, --all-mutations  Only print mutations (by default both queries and\n                       mutations are printed).\n\n  -h, --help           Show this message and exit.\n```\n\n## Usage of the Python library\n\nImport the library:\n\n```python\n\u003e\u003e\u003e from gqlspection import GQLSchema\n```\n\nSend introspection query and print a single query:\n\n```python\n\u003e\u003e\u003e schema = GQLSchema(url='https://.../graphql')\n\u003e\u003e\u003e query = schema.generate_query('SOME_TYPE')\n\u003e\u003e\u003e print(query.str)\n```\n\nParse introspection schema from a JSON file and print all mutations:\n\n```python\n\u003e\u003e\u003e from pathlib import Path\n\u003e\u003e\u003e import json\n\u003e\u003e\u003e data = json.loads(Path(FILE_NAME).read_text())\n\u003e\u003e\u003e schema = GQLSchema(json=data)\n\u003e\u003e\u003e for field in schema.mutation.fields:\n\u003e\u003e\u003e     print(schema.generate_mutation(field).str())\n```\n\n## Contributing\n\nInstallation with development dependencies from git repo:\n\n```bash\n$ git clone https://github.com/doyensec/GQLSpection.git\n$ cd GQLSpection\n$ virtualenv venv\n$ . ./venv/bin/activate\n$ pip install -e \".[dev]\"\n$ # Only needed in ZSH to locate newly added binaries:\n$ rehash\n$ pre-commit install\n```\n\n### Using runme\n\nInstall `runme` from https://github.com/sigoden/runme (through `cargo install --force runme` or by grabbing a binary\nrelease). Get a list of preinstalled development commands by running `runme` in the source dir:\n\n```commandline\n$ runme\nUSAGE: Runmefile.sh \u003cCOMMAND\u003e\n\nCOMMANDS:\n  deps                    Install development dependencies\n  test                    Run tests\n  jython.install          Install Jython to jython/\n  jython.clean            Cleanup after Jython\n  jython.test             Run tests to check Jython compatibility [aliases: jython]\n  lint                    Run linters\n  clean                   Cleanup bytecode and cache files\n  coverage.calculate      Run pytest with coverage calculation [aliases: coverage]\n  coverage.github_action  Generate comment body with coverage for Github Action\n  build                   Build the python release (files go to dist/)\n  publish.pypi            Publish release to PyPI\n  publish.github          Publish release to Github\n  release                 Make a new release\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoyensec%2FGQLSpection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoyensec%2FGQLSpection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoyensec%2FGQLSpection/lists"}