[Bug]: 2.0 rejects filter-variable queries with HC0047; Hot Chocolate cost limits are not configurable
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 Startup.AddGraphQLService 开始,据报告其中没有调用 ModifyCostOptions,并检查 runtime.graphql 对现有 depth-limit 设置的处理。执行 dab init 后,将带有筛选器变量的查询 POST 到 /graphql 以重现问题,然后验证成本行为是可配置的,并且通过变量提供的有效筛选器不再意外地以 HC0047 失败。
由索引模型根据 Issue 内容生成。
描述
[Bug]: 2.0 GA rejects filter: $variable queries with HC0047 — cost limits are not configurable
What happened?
After upgrading from 1.7.93 to 2.0.8, every query that passes a whole filter input as a GraphQL variable fails with:
{
"errors": [{
"message": "The maximum allowed field cost was exceeded.",
"extensions": { "code": "HC0047", "fieldCost": 1325, "maxFieldCost": 1000 }
}]
}
Hot Chocolate 16 (bundled since 2.0) enables static cost analysis by default with MaxFieldCost = 1000, and DAB exposes no configuration for it — runtime.graphql only has depth-limit; ModifyCostOptions is never called in Startup.AddGraphQLService.
Why this breaks virtually every real client
Generated *FilterInput types are self-referential (and: [XFilterInput!], or: [XFilterInput!]). When a filter is supplied as a variable, the cost analyzer prices the input type's recursive worst case, not the actual value. Measured against a DAB 2.0.8 instance (MSSQL, 131 entities) using GraphQL-Cost: validate:
| query shape | fieldCost |
|---|---|
organizations(first: 20) { items { id } } |
30 |
same + inline literal filter {status: {name: {in: [$name]}}} |
33 |
same + filter: $f variable (no value even supplied) |
1243 |
The ~1200 floor is entity-independent — a 3-column lookup table's filter variable prices at ~1202 — so every filter: $variable query exceeds the 1000 default. In our app that's 79 call sites across 48 routes, i.e. every list page. filter: $variable is the natural pattern for dynamic filtering (and what most GraphQL client codegen produces), and it worked on 1.x.
Related upstream: ChilliCream/graphql-platform#9548 (cost assumes two levels of recursion for circular references).
Expected
Either (preferably both):
runtime.graphqlconfig for cost analysis — e.g.cost: { enforce: bool, max-field-cost: int, max-type-cost: int }— mirroring the existingdepth-limitknob.- Defaults that don't reject variable-supplied filters on every entity (e.g. enforcement off unless configured, or variable inputs priced by provided value rather than recursive worst case).
Steps to reproduce
dab initagainst any MSSQL database, add any table entity, start DAB 2.0.8.POST /graphqlwithquery Q($f: <Entity>FilterInput) { <entities>(filter: $f) { items { __typename } } }and any (or no) variable value.- Observe HC0047 with fieldCost ≈ 1200+ vs maxFieldCost 1000.
Version
2.0.8 (the v2.0.9 tag contains no cost-related changes, so it is equally affected)
What database are you using?
Azure SQL / SQL Server
What hosting model are you using?
Container (App Service)
- 主要语言
- C#
- 星标
- 1.5k
- 派生
- 371
- 平均合并
- 9 天 2 小时
- 30 天内合并 PR
- 10
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Azure/data-api-builder 的其他 Issue
-
pgsql
难度 2/5 1-3 小时 新手友好度 68/100
Azure/data-api-builder#3598 ·
维护者通常 1 天内回复
-
2.x cli mcp-server
难度 2/5 1-3 小时 新手友好度 68/100
Azure/data-api-builder#3576 ·
维护者通常 1 天内回复
-
2.x health-endpoint
难度 2/5 1-3 小时 新手友好度 68/100
Azure/data-api-builder#3570 ·
维护者通常 1 天内回复
-
2.x telemetry
难度 2/5 1-3 小时 新手友好度 68/100
Azure/data-api-builder#3564 ·
维护者通常 1 天内回复
-
2.x telemetry
难度 2/5 1-3 小时 新手友好度 70/100
Azure/data-api-builder#3562 ·
维护者通常 1 天内回复
查看 Azure/data-api-builder 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
fluentassertions/fluentassertions#3353 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 半天 新手友好度 78/100
unoplatform/uno#24769 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
AvaloniaUI/Avalonia#22323 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
microsoft/onnxruntime-genai#2633 ·
维护者通常 1 天内回复