graphql-python / graphql-python/graphql-core-legacy
Cannot subscribe to more than one field
- Vorherrschende Sprache
- Python
- Sterne
- 372
- Forks
- 175
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Attempting to subscribe to more than one field will only return the first one in the list. There is some obvious offending code in executor.py:
`def subscribe_fields(exe_context, parent_type, source_value, fields):
exe_context = SubscriberExecutionContext(exe_context)
def on_error(error):
exe_context.report_error(error)
def map_result(data):
if exe_context.errors:
result = ExecutionResult(data=data, errors=exe_context.errors)
else:
result = ExecutionResult(data=data)
exe_context.reset()
return result
observables = []
# assert len(fields) == 1, "Can only subscribe one element at a time."
for response_name, field_asts in fields.items():
result = subscribe_field(exe_context, parent_type, source_value, field_asts, [response_name])
if result is Undefined:
continue
def catch_error(error):
exe_context.errors.append(error)
return Observable.just(None)
# Map observable results
observable = result.catch_exception(catch_error).map(
lambda data: map_result({response_name: data}))
return observable
observables.append(observable)
return Observable.merge(observables)
`
The line `return observable` causes a bunch of unreachable code and exits the loop early. However, commenting out that line does not appear to fix the problem - if it is removed, only the last item in the subscription list will return.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne in executor.py bei subscribe_fields und reproduziere eine Subscription, die mehrere Felder anfordert. Verfolge, wie das Ergebnis jedes Feldes in ein Observable umgewandelt wird und wie das zusammengeführte Ergebnis zurückgegeben wird. Erledigt ist es, wenn jedes angeforderte Feld im Subscription-Ergebnis erscheint und Fehler weiterhin korrekt gemeldet werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- api
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100