-
-
Notifications
You must be signed in to change notification settings - Fork 547
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
(imp) fastapi: GraphQLRouter typing #3781
(imp) fastapi: GraphQLRouter typing #3781
Conversation
Reviewer's Guide by SourceryThis pull request enhances the typing of FastAPI's GraphQLRouter by making Context and RootValue explicitly generic. It refines the type annotations in the class definition and methods, ensuring more robust typing support. Additionally, a release note is added to document this patch. Updated Class diagram for GraphQLRouter EnhancementclassDiagram
%% Base classes and interfaces
class APIRouter
class Generic
%% GraphQLRouter definition
class GraphQLRouter {
+bool allow_queries_via_get
+ASGIRequestAdapter request_adapter_class
+__get_context_getter(custom_getter: Union[Callable[..., Optional[Context>], Callable[..., Awaitable[Optional[Context>>): Callable[..., Awaitable[CustomContext]]
+__init__(root_value_getter: Optional[Callable[[], RootValue]], context_getter: Union[None, Callable[..., Optional[Context]], Callable[..., Awaitable[Optional[Context]]]], ...)
}
%% Inheritance and generic usage
GraphQLRouter --|> APIRouter : inherits
GraphQLRouter ..> Generic : generic{Context, RootValue}
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 @alexey-pelykh - I've reviewed your changes - here's some feedback:
Overall Comments:
- It's great to see the RELEASE.md file updated with the release type and a brief description of the changes.
- Consider adding a test case that specifically checks the typing of the
GraphQLRouter
with customContext
andRootValue
types.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 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.
RELEASE.md
Outdated
This release adjusts the fastapi `GraphQLRouter` typing to redeclare | ||
`Context` and `RootValue` as generic parameters. |
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.
suggestion: Clarify generic parameters and add an example
It would be helpful to clarify what these generic parameters are (e.g., Context
and RootValue
) and provide a short example of how this change affects users. This would make the release notes more informative and easier to understand.
Thanks for adding the Here's a preview of the changelog: This release adjusts the fastapi Here's the tweet text:
|
@bellini666 sort-of a follow-up on #3763 - what's your opinion? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3781 +/- ##
=======================================
Coverage 97.24% 97.24%
=======================================
Files 502 503 +1
Lines 33481 33495 +14
Branches 1714 1714
=======================================
+ Hits 32558 32572 +14
Misses 706 706
Partials 217 217 |
CodSpeed Performance ReportMerging #3781 will not alter performanceComparing Summary
|
eac2af0
to
8ec4d36
Compare
8ec4d36
to
e1e3986
Compare
Description
Seems like fastapi's
GraphQLRouter
is sort-of generic with Context and RootValue being non-passable explicitly.Types of Changes
Checklist
Summary by Sourcery
Enhancements: