[graphiql] Variables JSON parse error is indistinguishable from a server response and cannot be customized
Author: limarkxxCreated Sep 11, 2026Updated Sep 13, 2026
Problem
When the Variables (or Headers) pane contains malformed JSON, run() in @graphiql/react parses it client-side, writes an error into the response pane, and returns without sending a request:
{
"errors": [
{
"message": "Variables are invalid JSON: ValueExpected."
}
]
}Source: stores/execution.ts (tryParseJSONC → setError → return) and utility/jsonc.ts.
Three issues with this:
- It looks like a server response. The error is rendered in the same
{ errors: [...] }shape and place as a real response, with no indication that no request was made. - The message is not user-friendly.
ValueExpectedis the barejsonc-parserenum name; a plain-language description and a line/column would help, andjsonc-parseralready reportsoffsetandlengthfor each error. - There is no way to change it. No prop or callback covers this,
ExecuteButtonis not replaceable, and no plugin hook runs beforerun(). Workarounds require aliasing or patching internal module paths.
Related
- Apollo Sandbox parses variables client-side too, but strips the invalid content, shows a toast ("Invalid content in variables… was stripped from the request"), and forwards the request so the server's own message is what appears in the response pane.
- #780 introduced JSONC variables and this parser; it didn't discuss the error path.
- #3331 lists a future
variablesplugin type but nothing scheduled.
Environment
graphiql5.2.2,@graphiql/react0.37.3,jsonc-parser3.3.1- Same behavior on
mainas of 2026-09-11
Repro
- Query:
query Q($id: Int!) { node(id: $id) { id } } - Variables pane:
{"id": } - Press Run. Observe the
errorsblock above in the response pane and no network request.
Source: graphql/graphiql