GQLSpection
CLI tool and Python 2.7+ compatible library for parsing GraphQL introspection query and automatic query generation.
Installation
GQLSpection is available on PyPI (Python 2.7 and Python 3+ versions are supported).
Regular installation:
$ pip install gqlspection[cli]
Usage of the CLI tool
Load schema from file and print all query and mutation names in the schema:
$ gqlspection -f schema.json -l all
Send introspection query and generate queries & mutations for everything:
$ gqlspection -u https://.../graphql
Generate a single query:
$ gqlspection -u https://.../graphql -q something
Generate a number of mutations:
$ gqlspection -f schema.json -m one,two,three
Full help
$ ./gqlspection -h
Usage: gqlspection [OPTIONS]
Options:
-f, --file TEXT File with the GraphQL schema (introspection JSON).
-u, --url TEXT URL of the GraphQL endpoint with enabled introspection.
-l, --list TEXT Parse GraphQL schema and list queries, mutations or
both of them (valid values are: 'queries', 'mutations'
or 'all').
-q, --query TEXT Only print named queries (argument is a comma-separated
list of query names).
-m, --mutation TEXT Only print named mutations (argument is a comma-
separated list of mutation names).
-Q, --all-queries Only print queries (by default both queries and
mutations are printed).
-M, --all-mutations Only print mutations (by default both queries and
mutations are printed).
-h, --help Show this message and exit.
Usage of the Python library
Import the library:
>>> from gqlspection import GQLSchema
Send introspection query and print a single query:
>>> schema = GQLSchema(url='https://.../graphql')
>>> query = schema.generate_query('SOME_TYPE')
>>> print(query.str)
Parse introspection schema from a JSON file and print all mutations:
>>> from pathlib import Path
>>> import json
>>> data = json.loads(Path(FILE_NAME).read_text())
>>> schema = GQLSchema(json=data)
>>> for field in schema.mutation.fields:
>>> print(schema.generate_mutation(field).str())
Contributing
Installation with development dependencies from git repo:
$ git clone https://github.com/doyensec/GQLSpection.git
$ cd GQLSpection
$ virtualenv venv
$ . ./venv/bin/activate
$ pip install -e ".[dev]"
$ # Only needed in ZSH to locate newly added binaries:
$ rehash
$ pre-commit install
Using runme
Install runme from https://github.com/sigoden/runme (through cargo install --force runme or by grabbing a binary
release). Get a list of preinstalled development commands by running runme in the source dir:
$ runme
USAGE: Runmefile.sh <COMMAND>
COMMANDS:
deps Install development dependencies
test Run tests
jython.install Install Jython to jython/
jython.clean Cleanup after Jython
jython.test Run tests to check Jython compatibility [aliases: jython]
lint Run linters
clean Cleanup bytecode and cache files
coverage.calculate Run pytest with coverage calculation [aliases: coverage]
coverage.github_action Generate comment body with coverage for Github Action
build Build the python release (files go to dist/)
publish.pypi Publish release to PyPI
publish.github Publish release to Github
release Make a new release
Metadata
Release files for gqlspection 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gqlspection-0.2.3.tar.gz | 28.5 kB | Without provenance | Details for gqlspection-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gqlspection-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for gqlspection-0.2.3-py3-none-any.whl |
Total release size: 51.5 kB
Release files / gqlspection-0.2.3.tar.gz
| Download URL | gqlspection-0.2.3.tar.gz |
|---|---|
| Size | 28.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d10f5bc20c35180735996c4a04f5204e2b411ade0c6df71b1852607e1400ca30
|
|
BLAKE2b-256 checksum How to use checksums |
9508b8b3cafed7d3d80befc8e57038ddb1445d0b34907b43c897d2a900c6e4fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / gqlspection-0.2.3-py3-none-any.whl
| Download URL | gqlspection-0.2.3-py3-none-any.whl |
|---|---|
| Size | 23.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3b4fbad4d6e349888c57f8187aa71d2c71eb703cd25315613341999266d9eb72
|
|
BLAKE2b-256 checksum How to use checksums |
c335eaa607660d4d23796dfe446ff667d3a2bf85489449bdd88aac99f76b6788
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Security for gqlspection 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.