api-gql executes GraphQL operations (and optional variables), prints response JSON to stdout, keeps optional history, and can generate Markdown reports.
Usage: api-gql <command> [args]
Commands:
call Execute an operation and print response JSON (default)
history Print the last (or last N) history entries
report Generate a Markdown API test report
report-from-cmd Generate a report from a command snippet (arg or stdin)
schema Resolve a schema file path (or print schema contents)
completion Print shell completion script (bash | zsh)
Help:
api-gql --help
api-gql <command> --help # call | history | report | report-from-cmd | schema | completion
call(default): Execute an operation (and optional variables) and print response JSON. Positional:[operation.graphql](path to a*.graphqlfile),[variables.json](optional). Options:-e/--env <name>,-u/--url <url>,--jwt <name>,--config-dir <dir>,--list-envs,--list-jwts,--no-history.history: Print the last entry or tail N entries. Options:--config-dir <dir>,--file <path>,--last,--tail <n>,--command-only.report: Generate a Markdown report for an operation. Required:--case <name>,--op <file>. Exactly one of--runor--response <file|->. Options:--vars <file>,--out <path>,-e/--env <name>,-u/--url <url>,--jwt <name>,--allow-empty,--no-redact,--no-command,--no-command-url,--project-root <path>,--config-dir <dir>. Aliases:--operationfor--op,--variablesfor--vars,--expect-emptyfor--allow-empty.report-from-cmd: Generate a report from a command snippet. Positional:[snippet](or pass--stdinto read from stdin). Options:--case <name>,--out <path>,--response <file|->,--allow-empty,--dry-run,--stdin.schema: Resolve a schema file path (or print schema contents). Options:--config-dir <dir>,--file <path>(overrides env +schema.env),--cat.completion: Print shell completion script forbashorzsh.
- The first positional arg is an operation file path; conventional extension is
*.graphql(the runtime treats the whole file as the operation body and does not enforce the suffix). - The second positional arg is an optional variables file; it must be valid JSON. Numeric
fields named
limitare bumped up toGQL_VARS_MIN_LIMIT(default5) at load time.
api-gql schema resolves the schema file using this order:
--file <path>(CLI flag).GQL_SCHEMA_FILEenvironment variable.GQL_SCHEMA_FILEdeclared in<setup_dir>/schema.envorschema.local.env(last-wins).- Fallback filenames inside the setup dir:
schema.gql,schema.graphql,schema.graphqls,api.graphql,api.gql.
By default the resolved path is printed; pass --cat to print the file contents instead.
The following snippets are illustrative — replace paths and env names to match your setup.
# List endpoint presets discovered under setup/graphql/
api-gql call --list-envs
# Execute an operation against a preset, with variables
api-gql call --env staging operations/users.graphql operations/users.vars.json
# Generate a Markdown report by running the request now
api-gql report --case users-list --op operations/users.graphql \
--vars operations/users.vars.json --env staging --run
# Generate a report from a previously captured response
api-gql report --case users-list --op operations/users.graphql \
--response captured/users.json
# Replay a history snippet (e.g. last entry) into a report
api-gql history --last --command-only | api-gql report-from-cmd --stdin --response -
# Resolve and print the schema file path
api-gql schema --config-dir setup/graphql--jwt <name>orGQL_JWT_NAMEselectsGQL_JWT_<NAME>from the setupjwts.env/.localfiles.- If no JWT profile is selected, fallback uses
ACCESS_TOKENthenSERVICE_TOKEN. - History entries record the env source as
token=ACCESS_TOKENortoken=SERVICE_TOKEN.