-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow subscribe function to return a Promise #895
Comments
So if I understand correctly, the use case for adding additional API is in order to reject the subscription at the first place. Personally I feel that adding another API would just create more mess but I see that there are a lot of likes to your suggestion so I would love to be persuaded differently. |
We have 2 use cases. The first is the error use case. However, our more common use case is having to lookup information based on the subscription parameters to determine what channels to subscribe to. I don't see this as introducing a new API. This is just allowing the AsyncIterable to be returned at a later time via a Promise instead of immediately. |
@NeoPhi thanks for filing this issue. Can you help me understand your use-case in more depth? What's wrong with handling an AsyncIterator that throws on the first invocation of
It's certainly more verbose of an API, but it explicitly captures all the success/error cases. Thoughts? |
The primary use case is that we have a subscription in which the client passes in a couple of arguments. We have asynchronous business logic that runs which translates those arguments into a set of channel names that an AsyncIterable then listens on, hence our desire to be able to have the |
I just ran into this as well. The use case is to validate the user has permission to subscribe based on the arguments provided -- before starting the subscription. |
It does. Thank you! |
The current
subscribe
resolve logic does not permit returning a Promise that would resolve to an AsyncIterable. The use case is running asynchronous business logic to determine if the subscription should be allowed or additional information needed to return a valid AsyncIterable. While it would be possible to merge that logic into a high order iterable, I feel the ability to return a Promise would better match the existing GraphQL semantics.The text was updated successfully, but these errors were encountered: