Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug]: 2.0 rejects filter-variable queries with HC0047; Hot Chocolate cost limits are not configurable

未关闭
#3,748 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
csharp, graphql
领域
api, backend

调研方向

从 Startup.AddGraphQLService 开始,据报告其中没有调用 ModifyCostOptions,并检查 runtime.graphql 对现有 depth-limit 设置的处理。执行 dab init 后,将带有筛选器变量的查询 POST 到 /graphql 以重现问题,然后验证成本行为是可配置的,并且通过变量提供的有效筛选器不再意外地以 HC0047 失败。

由索引模型根据 Issue 内容生成。

描述

cri graphql

[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):

  1. runtime.graphql config for cost analysis — e.g. cost: { enforce: bool, max-field-cost: int, max-type-cost: int } — mirroring the existing depth-limit knob.
  2. 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

  1. dab init against any MSSQL database, add any table entity, start DAB 2.0.8.
  2. POST /graphql with query Q($f: <Entity>FilterInput) { <entities>(filter: $f) { items { __typename } } } and any (or no) variable value.
  3. 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

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Azure/data-api-builder 的其他 Issue

查看 Azure/data-api-builder 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。