-
-
Notifications
You must be signed in to change notification settings - Fork 543
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
Fix root value and context getter types #3712
Fix root value and context getter types #3712
Conversation
Reviewer's Guide by SourceryThis PR improves type safety by updating return types in ASGI and Django views to be more specific and consistent with other integrations. The changes replace generic Updated class diagram for Django and ASGI viewsclassDiagram
class GraphQLView {
+Optional~RootValue~ get_root_value(HttpRequest request)
+Context get_context(HttpRequest request, HttpResponse response)
+TemporalHttpResponse get_sub_response(HttpRequest request)
}
class ASGIView {
+Optional~RootValue~ get_root_value(Union~Request, WebSocket~ request)
+Context get_context(Union~Request, WebSocket~ request, HttpResponse response)
}
class StrawberryDjangoContext {
+HttpRequest request
+HttpResponse response
}
GraphQLView --> StrawberryDjangoContext
ASGIView --> StrawberryDjangoContext
note for GraphQLView "Updated return types for get_root_value and get_context methods"
note for ASGIView "Updated return types for get_root_value and get_context methods"
File-Level Changes
Possibly linked issues
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: all looks good
- 🟢 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: In this release, the return types of the Here's the tweet text:
|
CodSpeed Performance ReportMerging #3712 will not alter performanceComparing Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3712 +/- ##
==========================================
- Coverage 97.02% 96.68% -0.34%
==========================================
Files 500 500
Lines 33483 33473 -10
Branches 5593 5576 -17
==========================================
- Hits 32486 32364 -122
- Misses 793 877 +84
- Partials 204 232 +28
|
Description
This PR updates the ASGI and Django view to use the same return types as all other integrations (instead of just
Any
).Unfortunately, as with the other integrations, we have to use
# type: ignore
for the default context we provide.This will stay like that until we dictate a base class for contexts (or use PEP 696?).
Types of Changes
Summary by Sourcery
Update the return types of get_root_value and get_context methods in ASGI and Django views to align with other integrations, enhancing type consistency. Add a release note documenting these changes.
Enhancements:
Documentation: