GraphQL: Syntax Error: Expected Name, found <EOF> / Unexpected }
The GraphQL document is malformed — unbalanced braces, a stray comma/character, or an empty query.
Seen on:
REST API
Meaning
Usually a typo when hand-writing queries, a template literal that didn’t interpolate, or sending JSON where a query string is expected.
Common causes
- Unbalanced braces/parentheses
- Empty query or query not sent as a string
- Invalid characters or string interpolation mistakes
- Fragments referenced but not included
⚡ Quick fix
- Validate the query in GraphiQL/Apollo Sandbox
- Use gql tagged templates / codegen
- Log the exact query string sent
Detailed fix by platform
JavaScript
- javascript
import { gql } from "@apollo/client"; const GET_USER = gql`query GetUser($id: ID!) { user(id: $id) { id name } }`;
How to diagnose
- Query — Exact string sent
- Tooling — Linting/codegen errors
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in API
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026