Azure / Azure/data-api-builder

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

Aperta
#3,229 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
cri graphql
Lingua principale
C#
Stelle
1.5k
Fork
370
Merge medio
3g 17h
PR unite (30g)
8

Descrizione

### 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia riproducendo la query GraphQL fornita con due alias per l'entità books, quindi segui l'implementazione del resolver descritta nell'issue e individua dove le selezioni vengono memorizzate usando il nome dell'entità come chiave del dizionario. Il lavoro è completato quando entrambe le selezioni con alias restituiscono i rispettivi risultati filtrati separatamente senza un errore di chiave duplicata, con una copertura di regressione per questa query.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp, graphql
Ambito
api, backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.