Switch to graphql-transport-ws subprotocol - #821
Conversation
feb91ec to
9d7c5f8
Compare
|
Requested a review from Copilot to try this out for the first time... |
There was a problem hiding this comment.
Pull request overview
Switches the UI Server’s WebSocket GraphQL subscriptions to the graphql-transport-ws subprotocol and updates the server-side message handling to follow the newer protocol semantics.
Changes:
- Updated subscription WebSocket protocol constant and message handling (
graphql-transport-ws, new message types, ping/pong, subscribe/next/complete). - Simplified subscription handler state management by making
sub_statuseshandler-local and updated resolvers context wiring accordingly. - Updated tests and added a changelog entry for the protocol change.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| cylc/uiserver/tests/test_handlers.py | Updates the subprotocol selection test to the new protocol. |
| cylc/uiserver/handlers.py | Switches the selected WebSocket subprotocol constant and adjusts subscription handler initialization/state. |
| cylc/uiserver/graphql/tornado_ws.py | Implements graphql-transport-ws message types and updates subscription server message processing logic. |
| cylc/uiserver/authorise.py | Tightens typing for AuthorizationMiddleware.auth. |
| cylc/uiserver/app.py | Removes app-level sub_statuses plumbing now that subscription status is handler-local. |
| changes.d/821.feat.md | Documents the protocol change in the changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def select_subprotocol(self, subprotocols): | ||
| return GRAPHQL_WS | ||
| return WS_PROTOCOL |
There was a problem hiding this comment.
We are simultaneously upgrading the client (cylc/cylc-ui#2548) so this is not a problem (apart from the awkwardness of running development UI/UIS for a while when different branches have different subprotocols)
| if not isinstance(payload, dict): | ||
| raise AssertionError("The payload must be a dict") | ||
| assert op_id, "The message must have an operation ID" |
There was a problem hiding this comment.
Could be resolved by this I suppose
diff --git a/cylc/uiserver/graphql/tornado_ws.py b/cylc/uiserver/graphql/tornado_ws.py
index ffb9ebe..faebd89 100644
--- a/cylc/uiserver/graphql/tornado_ws.py
+++ b/cylc/uiserver/graphql/tornado_ws.py
@@ -436,7 +436,6 @@ class TornadoSubscriptionServer:
if not isinstance(parsed_message, dict):
raise AssertionError("Message must be an object")
+ self.process_message(connection_context, parsed_message)
except Exception as e:
connection_context.ws.close(4400, str(e))
return None
-
- self.process_message(connection_context, parsed_message)| await self.on_subscribe(connection_context, op_id, params) | ||
|
|
||
| case OperationType.COMPLETE.value: | ||
| assert op_id, "The message must have an operation ID" |
7e7f23f to
ffd0d7b
Compare
This allows for choosing the right UI build for graphql-transport-ws
d87a94c to
029fd70
Compare
Closes #690
Implements the
graphql-transport-wssubprotocol as defined in https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.mdSibling: cylc/cylc-ui#2548
Check List
CONTRIBUTING.mdand added my name as a Code Contributor.?.?.xbranch.