# GraphQL: Syntax Error: Expected Name, found <EOF> / Unexpected }

**Code:** `GraphQL Syntax Error` · **Category:** API · **Seen on:** REST API

The GraphQL document is malformed — unbalanced braces, a stray comma/character, or an empty query.

## 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

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/api/graphql-syntax-error)
