strawberry
strawberry copied to clipboard
Bugfix/no 3385
Description
Fix a bug "a custom resolver with permission_classes doesn't accept @sync_to_async decorator" The root cause was inspect.iscoroutinefunction() function returns True only for functions defined with "async def". Now is_async function returns True for a resolver function decorated with @sync_to_async
Types of Changes
- [ ] Core
- [x] Bugfix
- [ ] New feature
- [ ] Enhancement/optimization
- [ ] Documentation
Issues Fixed or Closed by This PR
- https://github.com/strawberry-graphql/strawberry/issues/3385
Checklist
- [X] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [X] I have read the CONTRIBUTING document.
- [X] I have added tests to cover my changes.
- [X] I have tested the changes and verified that they work and don't break anything (as well as I can manage).
Summary by Sourcery
Fix the issue where custom resolvers with permission_classes did not work with the @sync_to_async decorator by updating the is_async function to recognize SyncToAsync instances.
Bug Fixes:
- Fix a bug where a custom resolver with permission_classes did not accept the @sync_to_async decorator by updating the is_async function to correctly identify such functions.
Documentation:
- Add a RELEASE.md file to document the patch release fixing the bug with custom resolvers and @sync_to_async.
Tests:
- Add a test to verify that a resolver function decorated with @sync_to_async works correctly with permission_classes.