-
-
Notifications
You must be signed in to change notification settings - Fork 120
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: Make sure that async fields always return Awaitables #646
Conversation
Async fields sometimes can return non-awaitable values, like when the optimizer is enabled and already prefetched the nested field. This can break some places that expect an awaitable, like strawberry's base field permissions. This change ensures that async fields always return an awaitable.
Reviewer's Guide by SourceryThis pull request fixes an issue where async fields could return non-awaitable values, potentially breaking functionality that expects awaitables. The change ensures that async fields always return an awaitable, addressing issue #639. Class diagram for AsyncPermission and Query classesclassDiagram
class AsyncPermission {
+async has_permission(source: Any, info: Info, **kwargs: Any) Union[bool, Awaitable[bool]]
}
class Query {
+list[Color] colors
}
class Color {
+strawberry.auto name
+list[Fruit] fruits
}
class Fruit {
+strawberry.auto name
}
Query --> Color : has
Color --> Fruit : has
Color --> AsyncPermission : uses
Fruit --> AsyncPermission : uses
File-Level Changes
Assessment against linked issues
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 @bellini666 - 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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #646 +/- ##
==========================================
+ Coverage 88.74% 88.77% +0.03%
==========================================
Files 41 41
Lines 3606 3607 +1
==========================================
+ Hits 3200 3202 +2
+ Misses 406 405 -1 ☔ View full report in Codecov by Sentry. |
Async fields sometimes can return non-awaitable values, like when the optimizer is enabled and already prefetched the nested field.
This can break some places that expect an awaitable, like strawberry's base field permissions.
This change ensures that async fields always return an awaitable.
Fix #639
Summary by Sourcery
Fix async fields to consistently return awaitables, addressing issues with components expecting awaitable results, and add tests to validate this behavior.
Bug Fixes:
Tests: