Description
Hi there,
From what I can gather in the current source, it's not possible to gather errors that happened on the producer side of the chan
that is used to stream subscription responses. Having only a channel, you can write responses, or close the channel. If, while streaming one of the messages, your backend database fails, you can't send a proper error message, saying why you are closing the subscription.
I propose adding an interface, like:
type SubscriptionError interface {
SubscriptionError() error
}
and if implemented, would be checked before resolving all the fields. If such a function returns an error, then it would be AddError()
'd, and return null
data immediately.
With such a mechanism, the top-level objects could gather errors in a field on that object before pushing it to the chan
, and expose it through SubscriptionError()
.
Feedback welcome, I was thinking my team could implement it and propose a PR, but wanted to open the discussion first. There are probably two dozens better solutions, please share :)