graphql-python / graphql-python/graphql-core-legacy
Middleware can not add errors to execution context without raising an error
- Lingua principale
- Python
- Stelle
- 372
- Fork
- 175
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Use case: I've written a middleware for limiting users to a daily quota of nodes. The middleware counts nodes of particular types we care about limiting, and when the user hits their limit the middleware will raise an exception saying that they've hit their limit.
This works great, except in the case of lists. In this case, we are returning to the user as many elements of the list as possible until they go over the limit, and then no more. In this case, the middleware can not raise an exception because that would prevent it from also returning the promise for the truncated list of data.
Ideally in the middleware I could call execution_context.report_error() from https://github.com/graphql-python/graphql-core/blob/b3a6bd0f89651af10a937e5270e46c696672a2e5/graphql/execution/base.py#L92 to add an error saying "your limit was hit, and list field XYZ has had its data truncated" to the list of reported errors, but then continue along and return the truncated list of data.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia leggendo graphql/execution/base.py intorno a ExecutionContext.report_error(), che l’issue identifica come il punto di ingresso rilevante. Traccia il modo in cui gli errori del middleware vengono attualmente sollevati e raccolti, quindi definisci il completamento come la possibilità di segnalare un errore mentre l’esecuzione continua e restituisce un elenco troncato. Nell’issue non è menzionato alcun file di test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend-api-design
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100