Why does a GraphQL explorer keep variables and HTTP headers in panes separate from the document?
answer
- The panes mirror the request being built
- Two layers stacked, not three fields
- One of them never enters the GraphQL request
- Named parameters: query, variables, operationName
- Variable keys drop the dollar sign
basics
~20 sBecause they belong to two different layers. The document and its variables are separate members of the GraphQL request itself, while headers are HTTP metadata carried outside it. The panes mirror the request the explorer is about to build.
solid answer
~50 sThe GraphQL over HTTP specification names the request parameters a client sends: `query` (the document text), `variables` (a map from variable name, without the `$`, to a JSON value), `operationName` (which operation to run when the document holds several), and `extensions`. The document pane and the variables pane fill two of those members; the operation selector fills a third. Headers — authorization, client identification, trace context — are HTTP metadata and never appear inside the GraphQL request at all, which is why they get their own pane. The separation is not cosmetic. Variable values are coerced against the types the operation declares, so a mistyped value fails as a request error before anything executes; and keeping values out of the document text preserves both correct escaping and the document's identity, which anything keyed on the document text depends on.
code
graphql · 9 linesquery ReleaseCredits($releaseId: ID!, $first: Int! = 25) {
release(id: $releaseId) {
title
credits(first: $first) {
role
person
}
}
}go deeper
Know that the document and its variables go into the GraphQL request body while headers ride on the HTTP request, and that variables-pane keys drop the $. Credentials belong in the headers pane, never in variables.
Explain the parameter names — query, variables, operationName, extensions — and how the panes map onto them. Be ready to say why variables are coerced against their declared types and what a default does when a key is omitted.
Show why variables are a production concern, not a convenience: escaping, type coercion, and one stable document text so registered-document lookups and per-operation logging and metrics do not fragment per value.
Own the convention across teams: documents parameterised rather than templated, operation names that are stable and meaningful, and a clear rule that authentication is transport metadata and never enters the schema as an argument.
## Three panes, two layers An explorer's layout is a picture of the request it is about to send, and that request has two layers stacked on top of each other. The inner layer is the **GraphQL request**. The GraphQL over HTTP specification names its parameters: `query` — the executable document text, whatever operations it contains; `variables` — a map of values for the variables the operation declares; `operationName` — which operation to execute when the document defines more than one; and `extensions` — a free map for protocol extensions. The document pane and the variables pane are editors for two of these; the explorer's "which operation" selector supplies the third when it is needed. The outer layer is **HTTP**. Authorization credentials, a client name and version, trace context, a request id — these are headers on the HTTP request. Nothing in the GraphQL request carries them, and a server reads them from the transport, not from the document. That is why the headers pane is separate from the other two rather than being another key you type into the variables JSON. A candidate who can say which pane feeds which layer has the whole model, and it immediately explains a class of confused debugging: an authorization token typed into the variables pane does nothing, because no operation declares a variable for it and the server was never going to look there. ## What the variables pane actually is It is JSON, and its keys are the variable names **without** the `$` sigil. The declarations live in the document, on the operation: ```graphql query ReleaseCredits($releaseId: ID!, $first: Int! = 25) { release(id: $releaseId) { title credits(first: $first) { role person } } } ``` ```json { "releaseId": "rel_9f3c14", "first": 12 } ``` The declared types are load-bearing. Before execution begins, each supplied value is coerced against the type its variable declares: a JSON string handed to an `Int!` variable, or a missing value for a non-null variable with no default, fails the request outright — no field resolves, and the response carries errors with no `data` key rather than a partly-filled object. A default in the declaration (`$first: Int! = 25`) applies when the variables map omits the key; note that explicitly supplying `null` is not the same as omitting the key, which trips people up when an explorer's variables pane is left with a leftover `"first": null`. ## Why not just paste the value into the document? An explorer lets you write `release(id: "rel_9f3c14")` directly, and for a one-off poke that is fine. As a habit it costs four separate things. **Escaping.** Values become part of the document's syntax. A track title containing a quote or a newline has to be escaped by hand, correctly, every time. A variable value is JSON that never touches the document grammar. **Type checking.** A variable is declared with a type and coerced against it, and a mismatch is caught before execution. A literal spliced into the document is checked as a literal, and the failure arrives less usefully. **Document identity.** With variables, one document text serves every call; with literals, every distinct value produces a different document. Anything that keys on the document text — a hash used to look up a registered document, a grouping dimension in logs and metrics — fragments into one entry per value, which is how a dashboard ends up with thousands of one-request "operations". **Reuse.** The document you tested in the explorer is the exact document the application ships, with only the values differing. A document with a literal embedded in it is not the one your application sends, and that difference is where a green explorer run stops predicting anything. ## Headers, and the cookie trap The headers pane is where credentials go, and it has one wrinkle worth knowing: an explorer running as a page in a browser cannot set every header. `Cookie` in particular is a header the browser controls — a page's fetch cannot set it directly, and whether the browser attaches the cookies it already holds depends on how the request was issued and on the origin. The practical consequence is that a browser-hosted explorer is often authenticated by a session cookie the browser is attaching for you, invisibly, with nothing in the headers pane to show for it. That is a habit worth building: when a request works in the explorer, read the headers pane *and* remember what the browser is adding underneath it, because that combination is what actually authenticated the call — and it is rarely what an application sends.
- When does the operation-name parameter actually matter?When the document defines more than one operation. With several operations in the text, the server cannot choose for you and needs `operationName` to say which to execute; an explorer surfaces this as a run-operation selector. With exactly one operation the parameter is optional, though sending it anyway is a good habit — it makes the operation name available to the server for logging and grouping without parsing the document.
- Someone puts their access token in the variables pane and the request is still unauthenticated. Why?Because variables only supply values for variables the operation declares, and those values reach field arguments — nothing more. Authentication is read from HTTP metadata by a layer that runs before execution and never inspects the variables map. Unless the schema deliberately declares a token argument, which is a poor design that also writes the credential into document-shaped logs, the value simply sits there unused.
- Is omitting a variable key the same as sending null for it?No, and the difference is easy to hit in a variables pane. An omitted key means the variable was not provided, so a declared default applies; an explicit null means the value null was provided, which overrides no default and fails outright if the variable is declared non-null. Leftover `"someArg": null` entries in a variables pane cause exactly this — a request that fails before execution while the document itself is fine.
The document and variables are the letter and the order form folded inside it; the headers are what is written on the outside of the packet. The carrier reads the outside and never opens the letter to find the address.
saying these in an interview costs you the question
- Thinks headers travel inside the GraphQL request body
- Puts credentials in the variables pane and expects authentication
- Splices literals into the document instead of declaring variables
- Keeps the dollar sign on keys in the variables JSON
- Treats an explicit null variable as equivalent to omitting it
- Assumes the browser sends nothing the headers pane does not show