-
Expected Behaviour
I do not expect the server to throw an error in this case, as an invalid/expired token is not a server error, but a client error. I tried looking through the docs/recipes, and tried updating our implementation to pretty much this recipe which essentially defines a method for checking auth that can be called in Actual Behaviour
Debug Information
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
Errors thrown in any of the handlers are unexpected and shouldn't be handled by graphql-ws. Please read the full recipe, you'll see below that the recipe implements a custom WS server for handling the instances of the graphql-ws/website/src/pages/recipes.mdx Lines 817 to 833 in e45d6b1 Alternatively, you can of course not throw in the handlers and gracefully close the connection. |
Beta Was this translation helpful? Give feedback.
For graceful handling without implementing your own server, you could just use a try/catch when validating the token and return false from
onConnect
. Something like:This is also showcased in the "ws server and client auth usage with token expirati…