Azure / Azure/data-api-builder
[Bug]: GraphQL Aliased Field Queries Cause Duplicate Dictionary Key Error for Same Entity
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 370
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 9
Description
### 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.
Contributor guide
Research direction
Start by reproducing the supplied GraphQL query with two aliases for the books entity, then trace the resolver implementation described in the issue and find where selections are stored using the entity name as a dictionary key. Done means both aliased selections return their separate filtered results without a duplicate-key error, with regression coverage for this query.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, graphql
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100