-
Couldn't load subscription status.
- Fork 569
fix(strawberry): Remove autodetection, always use sync extension #4984
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4984 +/- ##
=======================================
Coverage 83.96% 83.97%
=======================================
Files 165 165
Lines 17085 17089 +4
Branches 3001 3002 +1
=======================================
+ Hits 14346 14351 +5
Misses 1839 1839
+ Partials 900 899 -1
|
|
I have two thoughts:
I am worried that we would break some users by merging this because of reliance on the I'll take a look if there is a way to improve the auto-detection. If not, I think we should add a warning if the |
|
Let me know if you can think of anything wrt improving auto detection; that'd be my preferred way of doing things, but since we integrate too early to know anything useful about the user's app, I don't see a way forward there. The interop with (Also, all of this is just a band-aid. The proper solution is to make the whole integration opt-in so that folks have power over which extension should be used. But we can only do that in a major.) |
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.
Just recording: core of strawberry is agnostic between sync and async server frameworks, so I agree that there's no easy way to figure out if the async extension is safe to run.
Regarding interaction with the threading integration through sync_to_async, it would only be a problem on old asgiref versions that were needed on Python 3.6. So it's even less likely for users to be affected.
So looks good to me as is!
Description
Problem
There are two ways to instrument strawberry-graphl apps: via a sync or an async extension. We enable one or the other based on what web framework is installed (async framework -> async extension, sync framework -> sync extension). This auto-detection can be overridden via an integration option.
At some point (SDK 2.0?), we added
StrawberryIntegrationto auto-enabling integrations, which means the brittle auto-detection kicks in as soon as someone hasstrawberry-graphlinstalled. This can lead to issues, most notably when we auto-enable the async version of the extension even though the user's Strawberry app is actually sync.Options
This way we'll never mistakenly enable async code in a sync app. We also had a report at some point that the sync extension actually performs better than async, so enabling sync by default shouldn't be a big problem in async apps.
StrawberryIntegrationfrom auto-enabling integrations.Breaking change. People might just lose their traces and errors.
Best option, but out of ideas how to do this.
Went with 1), all things considered it's the least breaking change (unless there's a way to do 3). Needs a big callout in the changelog anyway though.
Issues
Closes #4980
Reminders
tox -e linters.feat:,fix:,ref:,meta:)