# GraphQL HTTP 413：查询负载过大

- **ID:** `api/graphql-http-413-payload-too-large-query`
- **领域:** api
- **类别:** resource_error
- **错误码:** `413`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

GraphQL 查询或变更主体超过了服务器配置的 HTTP 请求体大小限制（例如 Express/NGINX 中的默认 1 MB）。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Apollo Server 4.x | active | — | — |
| Express 4.18+ | active | — | — |
| NGINX 1.24+ | active | — | — |
| GraphQL Yoga 3.x | active | — | — |
| AWS API Gateway 2023+ | active | — | — |

## 解决方案

1. ```
   Increase the body size limit in Express middleware:
const express = require('express');
const app = express();
app.use(express.json({ limit: '10mb' })); // Increase to 10 MB
If using Apollo Server with Express, apply this before the Apollo middleware.
   ```
2. ```
   If using NGINX as a reverse proxy, increase client_max_body_size in the server block:
server {
    client_max_body_size 10m;
    ...
}
   ```

## 无效尝试

- **** — The body size limit is checked before query parsing. (60% 失败率)
- **** — GET requests have their own size limits (e.g., 8 KB for most servers) and are not suitable for large queries. (40% 失败率)
