# GraphQL 错误：参数“limit”的值无效：期望类型“Int!”，但得到“String”

- **ID:** `api/graphql-field-argument-type-mismatch`
- **领域:** api
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

客户端发送的 GraphQL 查询或变更中使用了错误类型的参数值（例如字符串而非整数）。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| GraphQL June 2018 | active | — | — |
| Apollo Server v4 | active | — | — |
| graphql-js v16 | active | — | — |

## 解决方案

1. ```
   Ensure the client sends the correct type: for integers, avoid quoting (e.g., `{ "query": "query { items(limit: 10) { id } }" }`).
   ```
2. ```
   Use a variable with a proper type definition: `query($limit: Int!) { items(limit: $limit) { id } }` and pass `{"limit": 10}` in the variables.
   ```

## 无效尝试

- **** — GraphQL strict typing rejects mismatched types unless coercion is explicitly defined. (90% 失败率)
- **** — Clients unaware of the custom scalar may still send strings. (60% 失败率)
