-
Notifications
You must be signed in to change notification settings - Fork 27
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
Subscription should guarantee at least one gqlData response to a gqlStart request #27
Comments
You're referring to https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md#gql_data I assume. I agree, this is something we are not doing yet but should do. |
That does look like it would solve my issue. I hope it can be merged as soon as possible. |
The reason I haven't merged the I can see that this is not obvious and certainly not the prettiest solution. The Would it be reasonable to make it mandatory for listeners to return an initial |
@Jannis I get your point. As the After having a good time on the subject, I think it's fine to have the We can also accept the implementator to return a |
@ccamel That sounds like a good approach. It will force people to think about why they'd return |
The Problem
According to what I've read, it seems that if a client sends a "gqlStart" to the server then the server should guarantee at least one "gqlData" response. Currently this doesn't happen, as "gqlData" responses are only sent when the server logic explicitly calls "Subscription.SendData()", which may never happen if the subscribed content isn't being updated.
I have two proposals for fixing this issue:
Solution 1: execute the query within this library within the "AddSubscription" function.
This would leave the exported functions of the library unchanged, but denies the server logic the ability to customize behaviour such as adding objects to the graphql query context.
Solution 2: allow or require the server logic to provide OnConnect callback functions
If the server logic could provide callback functions to the SubscriptionManager then the solution is entirely in the hands of the developer. As one possible way this could be approached, this would be near-identical to the existing implementation, except that instead of being created with a single argument, it would now also need a callback argument.
Before:
After:
It would even be possible to make this change to the existing implementation of SubscriptionManager directly without breaking any existing code by accepting a variadic number of callbacks, as the callback definitions would then be completely optional.
Alternative:
The text was updated successfully, but these errors were encountered: