type-graphql
type-graphql copied to clipboard
allow subscribe function to return promise
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
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
Related to #470 👀
Looks like this may be unblocked soon.
One of those got closed. Is this still blocked?
Probably not, will take a look at that soon 😉
Solved by #1578 🔒
https://github.com/MichalLytek/type-graphql/blob/v2.0.0-beta.4/src/decorators/types.ts#L31-L33