-
Notifications
You must be signed in to change notification settings - Fork 529
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
Handling close connection with GraphQLWSHandler #2481
Comments
@aleksandar78 looks like an omission to me. Would you like to contribute the enhancement? |
@tsegismont I found a way to pass the handler when the close socket event is called. This is the trick that works well but it's not clear on the GraphQLWSHandler API level, IMO. The solution could be exposing endHandler or adding an example in official documentation to explain how to handle this kind of situation. What do you think? Anyway, I'm available to help. |
Can you paste a snippet to better understand your workaround? |
This is kotlin pseudo-code passed to GraphQLWSHandler.connectionInitHandler
|
Thank you @aleksandar78 The problem with this code is that the WebSocket can have only one Lines 117 to 119 in 296064d
So, having an |
@tsegismont can you point to me vert.x contributor's guide (if any) before I make the pull request? Thanks |
https://github.com/eclipse-vertx/vert.x/blob/master/CONTRIBUTING.md First, you need to make a pull request to |
Closes #2481 Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
Closed by fe47bdf |
Closes #2481 Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
Describe the feature
Add endHandler(Handler endHandler) to GraphQLWSHandler.
Use cases
Until vert.x 4.* graphql subscription APIs have been protected (in my case) with the help of 3 methods of ApolloWSHandler:
This approach worked with ApolloWSHandler.
The handler above is deprecated. The suggestion is to use GraphQLWSHandler.
The main problem is that the GraphqlWSHandler has only connectionInitHandler and beforeExecute (substitution for queryContext). What is missing is endHandler.
I don't know if this was intentional or not but the common authentication flow with open connections has the problem of removing user info when the connection is closed. The end handler is very handy to keep the session map clean over time.
Implementation
Watching the source code of ApolloWSConnectionHandler (ApolloWSHandler) and ConnectionHandler (GraphQLWSHandler) I found the difference in close handler methods where:
ApolloWSConnectionHandler
ConnectionHandler
ConnectionHandler doesn't have any reference to endHandler. Maybe, by adding the reference the same behavior could be obtained.
I admit that this analysis is very superficial but it could be a starting point.
The text was updated successfully, but these errors were encountered: