Skip to content

Allow propagation of errors from Subscriptions channels into Request.Errs #314

Closed
@abourget

Description

@abourget

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions