GraphQL Syntax Error 🔌 API

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

  1. Validate the query in GraphiQL/Apollo Sandbox
  2. Use gql tagged templates / codegen
  3. Log the exact query string sent

Detailed fix by platform

JavaScript

  1. javascript
    import { gql } from "@apollo/client";
    const GET_USER = gql`query GetUser($id: ID!) { user(id: $id) { id name } }`;

How to diagnose

  1. Query — Exact string sent
  2. 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:

🧠 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.