Azure / Azure/data-api-builder

[Bug]: GraphQL Aliased Field Queries Cause Duplicate Dictionary Key Error for Same Entity

オープン
#3,229 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
cri graphql
主要言語
C#
スター
1.5k
フォーク
370
平均マージ
3日 22時間
マージ済み PR(30日)
9

説明

### Discussed in https://github.com/Azure/data-api-builder/discussions/2785

Originally posted by **ascii1010** July 24, 2025
```graphql
brochure: books(
filter: { type: { eq: "brochure" } }
) {
items {
id
description
}
}

magazine: books(
filter: { type: { eq: "magazine" } }
) {
items {
id
description
}
}
```

The above generates error:

```
An item with the same key has already been added. Key: books
```

## Theory

The issue is not GraphQL itself. It is the resolver implementation using the entity name as the dictionary key instead of the alias or a unique field identifier. Two selections of books are valid GraphQL, but the server code is deduplicating by entity name and therefore treating them as a duplicate dictionary key.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、提供された GraphQL クエリを books エンティティに対する 2 つのエイリアス付きで再現し、次に issue で説明されている resolver の実装を追跡して、エンティティ名を辞書のキーとして選択項目が保存されている箇所を見つけます。完了の条件は、両方のエイリアス付き選択項目が重複キーエラーなしでそれぞれ個別にフィルタリングされた結果を返し、このクエリに対するリグレッションカバレッジがあることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp, graphql
領域
api, backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。