GraphQL
recon graphql sends a GraphQL operation to an HTTP endpoint and splits the reply into data, errors and extensions. With --introspect it fetches the schema instead and lists the root queries, mutations and types. Use it to check a GraphQL API from a terminal or CI, where a GraphQL error should fail the step.
Quick example
Section titled “Quick example”Start the Studio server to get the offline GraphQL sandbox at /_sandbox/<env>/graphql. It answers introspection and a students query.
recon init --demorecon ui --port 4600 --no-open &recon graphql http://127.0.0.1:4600/_sandbox/local/graphql --introspectGraphQL Schema http://127.0.0.1:4600/_sandbox/local/graphql: 1 queries, 0 mutations, 1 types query students -> [Student]Run a query and mask PII in the result:
recon graphql http://127.0.0.1:4600/_sandbox/local/graphql \ --query 'query ListStudents { students { student_id email } }' --airlockGraphQL HTTP 200 (0.5ms, errors=0, airlock=true){ "environment": "local", "students": [ { "email": "micah.vaughn.9383@example.edu", "full_name": "Eli Bennett", "program": "MDiv", "student_id": "007218" }, { "email": "grace.whitaker.1593@example.edu", "full_name": "Ethan Mercer", "program": "MA", "student_id": "004148" } ]}The sandbox returns the same fixed student list for any query that is not introspection, so the fields in the reply do not follow the selection set.
Running an operation
Section titled “Running an operation”The query
Section titled “The query”Give the operation in one of two ways:
--query '<document>', or--query-file <path>. The path is read relative to the current directory, not the workspace.
If both are given, --query wins. If neither is given and --introspect is not set, the command fails with E_INVALID_ARGS and exit code 2.
recon graphql http://127.0.0.1:4600/_sandbox/local/graphql --query-file students.graphqlVariables and operation name
Section titled “Variables and operation name”--variables '<json>'is parsed as JSON and sent asvariables. Invalid JSON fails before anything is sent.--operation <name>is sent asoperationName.
What is sent
Section titled “What is sent”Every operation, including subscriptions, is sent as one HTTP POST to the URL with this JSON body:
{"operationName":null,"query":"{ student { id gpa } }","variables":null}operationName and variables are null when you do not set them. Recon adds Content-Type: application/json. Redirects are followed. The request timeout is --timeout-ms (default 15000, minimum effective value 500).
{{variables}} in the URL are resolved from the selected environment. The CLI has no flags for extra headers or auth.
How the reply is read
Section titled “How the reply is read”The response body must be JSON. Recon then reads:
| Field | Source |
|---|---|
data |
The data member, or null if it is missing. |
errors |
The errors array, or an empty array. |
extensions |
The extensions member, or null. |
has_errors |
true when the HTTP status is 400 or above, or errors is not empty. |
Errors and exit codes
Section titled “Errors and exit codes”GraphQL errors and HTTP errors both make the command exit with 1, so a partial result fails a CI step.
| Exit | Code | When |
|---|---|---|
0 |
Status below 400 and an empty errors array. |
|
1 |
has_errors is true: the reply had a non-empty errors array, or the status was 400 or above. The reply is still printed. |
|
1 |
E_FIREWALL_BLOCKED |
The secret firewall blocked the request. |
2 |
E_INVALID_ARGS |
No --query, --query-file or --introspect. |
2 |
E_CLI_RUNTIME |
Any other failure, for example GraphQL error: GraphQL HTTP 502 returned non-JSON body: ..., a message starting with invalid JSON in --variables, failed to read query file ..., or a network error. |
With --introspect, the command exits 0 when a schema is returned. It fails with E_CLI_RUNTIME and exit 2 when the reply has errors and no data (introspection failed (HTTP <status>): ...) or when data.__schema is missing.
Output
Section titled “Output”In human format Recon prints a summary line, then data as indented JSON, then Errors: and the errors array if there are any.
In json and agent format Recon prints the full response:
recon --format json graphql http://127.0.0.1:4600/_sandbox/local/graphql \ --query '{ students { student_id email } }' --variables '{"program":"MDiv"}' --operation ListStudents{ "status": 200, "total_ms": 0.339685, "data": { "environment": "local", "students": [ { "email": "elena.original@westminster.edu", "full_name": "Elena Vance-Original", "program": "MDiv", "student_id": "001001" },... ] }, "errors": [], "extensions": null, "has_errors": false, "headers": [ { "name": "content-type", "value": "application/json" },... ], "airlocked": false, "compliance_receipt": { "salt_fingerprint": "9d2de0d49b08", "fields_masked": 6, "secrets_scrubbed": 0, "headers_stripped": 0, "verified_zero_leak": true, "leaked_tokens_found": [], "receipt_hash": "438a075f71fa402f0e30ea9addbee2ca1505fd7710529e092339ab3835f9aafa" }}| Field | Meaning |
|---|---|
status |
HTTP status. |
total_ms |
Request time in milliseconds. |
data, errors, extensions, has_errors |
See How the reply is read. |
headers |
Response headers. |
airlocked |
true when --airlock was passed. |
compliance_receipt |
The PII Airlock receipt for the response. |
--airlock
Section titled “--airlock”With --airlock, the response body and headers pass through the PII Airlock before Recon parses them, so data, errors, extensions and headers all hold masked values.
The receipt is produced on every run. In the example above, fields_masked is 6 even though --airlock was off: the receipt counts what masking found, while the printed data is the raw reply.
Introspection
Section titled “Introspection”--introspect sends a fixed introspection query named ReconIntrospectionQuery. It asks for:
- the names of the query, mutation and subscription root types;
- for every type:
kind,name,description, and itsfields(including deprecated ones) with each field’sname,description,argsand returntype.
Argument and return types are requested four levels deep, so a type such as [ID!]! is fully resolved. The query does not ask for input fields, enum values, interfaces or directives.
Recon turns the reply into a summary:
| Field | Contents |
|---|---|
query_type, mutation_type, subscription_type |
Root type names, or null. |
queries |
Fields of the query root type: name, description, return_type, args (each with name and arg_type). |
mutations |
Fields of the mutation root type, in the same shape. |
types |
Every other type whose name does not start with __: name, kind, and the list of field names. |
source |
The URL you passed. |
Type references are rendered in GraphQL syntax: a non-null type gets a trailing ! and a list is wrapped in [ ]. A missing type is shown as Any.
Notes on the types list:
- It skips only the query and mutation root types and names starting with
__. The subscription root type and built-in scalars such asIDappear in it if the server lists them. - Input objects and enums are listed with an empty
fieldsarray, because the introspection query does not fetch input fields or enum values. - Fields of the subscription root type are not listed as operations.
In human format Recon prints the counts and one line per query and mutation. Types appear only in json and agent output.
recon --format json graphql http://127.0.0.1:4600/_sandbox/local/graphql --introspect{ "query_type": "Query", "mutation_type": null, "subscription_type": null, "queries": [ { "name": "students", "description": "List enrolled students", "return_type": "[Student]", "args": [ { "name": "program", "arg_type": "String" } ] } ], "mutations": [], "types": [ { "name": "Student", "kind": "OBJECT", "fields": [ "student_id", "full_name", "email", "program" ] } ], "source": "http://127.0.0.1:4600/_sandbox/local/graphql"}Mutations and agent policy
Section titled “Mutations and agent policy”Recon can tell a mutation from a query by the first keyword of the document. Lines that start with # are skipped, and the first word is compared to mutation without regard to case. A document that starts with a fragment or with the { shorthand counts as a query.
This check is used by the MCP tool recon_graphql, not by the CLI. When an agent calls the tool with a mutation, agent policy sees it as a POST, so a workspace with require_approval_for_mutations = true holds the call for human approval. A query or an introspection call is seen as a GET. For example, in the demo workspace (with approval_timeout_secs lowered to 2), a mutation call through MCP returned:
E_AGENT_APPROVAL_TIMEOUT: approval `01a22d26-4056-727b-a2d2-2101c7fafa9b` timed out after 2s without human decisionrecon graphql on the command line does not apply agent policy.
Secrets, auth and transport
Section titled “Secrets, auth and transport”-
Secret firewall. The resolved request passes through the Outbound Secret Firewall before it is sent. A secret in the URL that is not allowed for the host blocks the call with exit code
1:Terminal window recon graphql 'http://127.0.0.1:4600/_sandbox/local/graphql?key={{PROD_STRIPE_KEY}}' --query '{ students { student_id } }'error E_FIREWALL_BLOCKED: Blocked secret `PROD_STRIPE_KEY` bound for `api.stripe.com` from being sent to unauthorized host `127.0.0.1`.hint: Switch environment or update secret allowed_hosts. -
Auth and signing. The CLI and the MCP tool send no auth block and no extra headers; secret URIs in environment variables used in the URL are still resolved. The HTTP API routes take
headersand anauthblock, which supports the schemes on Auth & Request Signing. -
Transport.
recon graphqluses Recon’s main HTTP client, so the global--proxy,--no-proxy,--ca-cert,--client-cert,--client-key,--insecure,--cookiesand--cookie-jarflags apply, as do the defaults in.recon/network.json(unless--no-network-configis set). See Transport: TLS, Proxy & Cookies. With--cookie-jar, cookies are saved after the call.
recon graphql does not write to the Flight Recorder.
| Flag | Default | Description |
|---|---|---|
<URL> |
required | GraphQL endpoint. {{variables}} are resolved. |
--env <ENV> |
workspace default_env |
Environment used for variables and secrets. |
--query <DOC> |
none | Operation document. |
--query-file <PATH> |
none | Read the document from a file. Ignored when --query is set. |
--variables <JSON> |
none | Variables as a JSON string. |
--operation <NAME> |
none | Operation name. |
--introspect |
off | Fetch and summarise the schema instead of running an operation. |
--timeout-ms <MS> |
15000 |
Request timeout. Minimum effective value 500. Not used by --introspect. |
--airlock |
off | Mask PII in data, errors, extensions and headers. Not used by --introspect. |
Global flags such as --workspace, --format, --salt and the transport flags also apply. See the CLI Reference.
Also available via
Section titled “Also available via”| Surface | Name | Notes |
|---|---|---|
| MCP tool | recon_graphql |
Takes url (required), query, variables, operation_name, introspect, env. Airlock is always on and the timeout is 15000 ms. Mutations go through agent policy as described above. |
| HTTP API | POST /api/v1/graphql/run |
Body: request (url, query, optional variables, operation_name, headers, auth, timeout_ms, airlock) and optional env. Returns { "response": ... }. |
| HTTP API | POST /api/v1/graphql/introspect |
Body: url, optional headers, auth, env. Returns { "schema": ... }. See HTTP API. |
| Web Studio | Protocols, tab GraphQL | URL (default {{base_url}}/graphql), Introspect Schema, Execute Query, a query editor, a variables box, and a schema explorer listing queries, mutations and types. Clicking a query fills the editor with a template. The Airlock toggle starts on. Also opened from the command palette entry “Open GraphQL Studio & Schema Explorer”. |