Comments (8)
@aleksandar78 looks like an omission to me. Would you like to contribute the enhancement?
from vertx-web.
@tsegismont I found a way to pass the handler when the close socket event is called.
Inside connectionInitHandler where init Message is passed as the argument for the first time, the WebSocket instance can be used for the same purpose as endHandler in the ApolloWSHandler.
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.
from vertx-web.
Can you paste a snippet to better understand your workaround?
from vertx-web.
This is kotlin pseudo-code passed to GraphQLWSHandler.connectionInitHandler
fun onInit(event: ConnectionInitEvent) {
val socket = event.message().socket()
// validate token sent by graphql client
validateToken(event.message())
.compose { username ->
fetchUser(username)
}
.onSuccess { user ->
val textHandlerID = socket.textHandlerID()
sessionMap[textHandlerID] = user
socket.closeHandler {
sessionMap.remove(textHandlerID)
}
event.complete()
}
.onFailure { ex ->
val error = createAuthException(ex, socket)
event.fail(error)
}
}
from vertx-web.
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 closeHandler
, which means this will not be invoked:
So, having an endHandler
to set in io.vertx.ext.web.handler.graphql.ws.GraphQLWSHandler
and invoking it in io.vertx.ext.web.handler.graphql.impl.ws.ConnectionHandler#close
seems like the right thing to do
from vertx-web.
@tsegismont can you point to me vert.x contributor's guide (if any) before I make the pull request?
I can make the effort but I'm not familiar with your branching strategy.
Thanks
from vertx-web.
https://github.com/eclipse-vertx/vert.x/blob/master/CONTRIBUTING.md
First, you need to make a pull request to master
branch (which is where Vert.x 5 development happens now). Then you can backport to the 4.x
branch (by creating another pull request).
from vertx-web.
Related Issues (20)
- When the WebSocket connection is closed, the registrations is not clear! HOT 3
- CSRF Handler can "trap" users HOT 7
- BodyHandler: document setDeleteUploadedFilesOnEnd HOT 2
- FileUpload API improvements
- BodyHandler default body limit change HOT 1
- Vertx Web Validation circular refs tests are failing
- fail() in RoutingContextImpl constructor causes "Unhandled exception in router" even if error was handled
- converting routing context request to web socket returns text handler id as null. HOT 1
- ForwardedParser parse XFF IPV6. HOT 4
- sqlConnection.updateWithParams HOT 1
- VertxRest HOT 1
- Investigate if Vertx WebClient can support HTTP proxy server proxying HTTPS requests HOT 1
- Add webUser() method to io.vertx.ext.web.handler.graphql.ws.Message HOT 2
- vertx-web-graphql subscription onError() is not returning a payload of an array of GraphQLErrors HOT 1
- `BodyHandler` with `deleteUploadedFilesOnEnd=true` fail to clean temporary file HOT 1
- GraphQLWS: store the RoutingContext in GraphQLContext HOT 1
- Deprecate GraphQLHandler#getRoutingContext HOT 1
- Support request forwarding to Web API Service with new OpenAPI Router
- vertx-web-api-contract contains shaded dependencies with Critical CVE
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vertx-web.