type-graphql icon indicating copy to clipboard operation
type-graphql copied to clipboard

allow subscribe function to return promise

Open onichandame opened this issue 4 years ago • 5 comments

Is your feature request related to a problem? Please describe. The custom subscribe function passed to a subscription resolver is required to return AsyncIterator synchronously. However, there is async business logic that I need to run in the subscribe function. e.g. add/remove subscription count after an expensive async function is resolved/rejected.

Describe the solution you'd like as described in this issue, people are adding support for this feature.

Describe alternatives you've considered I am manipulating the count before running the async function as a workaround. But this is not an exact match of our initial design, which is based on the business logic. Therefore some unprecedented errors may emerge.

Additional context N/A

onichandame avatar Apr 26 '20 03:04 onichandame

The ResolverFn from graphql-subscriptions is synchronous, so we have to wait for the PRs to be merged: https://github.com/apollographql/graphql-subscriptions/pull/220 https://github.com/apollographql/graphql-subscriptions/pull/197

MichalLytek avatar Apr 26 '20 08:04 MichalLytek

Related to #470 👀

MichalLytek avatar May 03 '20 17:05 MichalLytek

Looks like this may be unblocked soon.

glen-84 avatar Nov 25 '21 20:11 glen-84

One of those got closed. Is this still blocked?

ericwooley avatar Jul 10 '23 23:07 ericwooley

Probably not, will take a look at that soon 😉

MichalLytek avatar Jul 11 '23 06:07 MichalLytek

Solved by #1578 🔒

https://github.com/MichalLytek/type-graphql/blob/v2.0.0-beta.4/src/decorators/types.ts#L31-L33

MichalLytek avatar Feb 25 '24 15:02 MichalLytek