-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
Let graphql-ws use type inference whenever possible #3704
Let graphql-ws use type inference whenever possible #3704
Conversation
Reviewer's Guide by SourceryThis PR enhances type inference in the legacy GraphQL WebSocket protocol by simplifying message handling and removing explicit type casting. The changes focus on consolidating WebSocket message sending through dedicated methods and improving type safety. Sequence diagram for WebSocket message handlingsequenceDiagram
participant Client
participant WebSocket
participant Handler
Client->>WebSocket: send_legacy_message({"type": "connection_init"})
WebSocket->>Handler: handle_connection_init
Handler->>WebSocket: send_message({"type": "connection_ack"})
Client->>WebSocket: send_legacy_message({"type": "start", "id": "demo", "payload": {"query": "subscription { echo(message: 'Hi') }"}})
WebSocket->>Handler: handle_async_results
Handler->>WebSocket: send_data_message(result, "demo")
Client->>WebSocket: send_legacy_message({"type": "stop", "id": "demo"})
WebSocket->>Handler: handle_stop
Handler->>WebSocket: send_message({"type": "complete", "id": "demo"})
Updated class diagram for WebSocket message handlingclassDiagram
class BaseGraphQLWSHandler {
+handle_connection_init(message: ConnectionInitMessage)
+handle_keep_alive()
+handle_async_results(operation_id: str)
+cleanup_operation(operation_id: str)
+send_data_message(execution_result: ExecutionResult, operation_id: str)
+send_message(message: OperationMessage)
}
class WebSocketClient {
+send_legacy_message(message: OperationMessage)
}
BaseGraphQLWSHandler <|-- WebSocketClient
note for BaseGraphQLWSHandler "Consolidated message sending methods for type safety"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @DoctorJohn - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟡 Testing: 3 issues found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Thanks for adding the Here's a preview of the changelog: This release refactors part of the legacy Here's the tweet text:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3704 +/- ##
=======================================
Coverage 96.71% 96.71%
=======================================
Files 500 500
Lines 33436 33438 +2
Branches 5590 5590
=======================================
+ Hits 32336 32340 +4
+ Misses 883 881 -2
Partials 217 217
|
CodSpeed Performance ReportMerging #3704 will not alter performanceComparing Summary
|
Description
This is a followup PR for #3689 briging the changes we discussed in #3701 also to the legacy protocol (i.e., using type inference whenever possible). I also made assertions in two related tests more precise.
Types of Changes