Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shmoon-kr committed Aug 18, 2024
1 parent b4575ab commit d4ed01d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Release type: patch

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".
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" in python < 3.12
10 changes: 6 additions & 4 deletions strawberry/types/fields/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ def is_reserved_type(self, other: builtins.type) -> bool:

T = TypeVar("T")

# asyncio.iscoroutinefunction was deprecated in python >= 3.12
if hasattr(inspect, "markcoroutinefunction"):
iscoroutinefunction = inspect.iscoroutinefunction

Check warning on line 177 in strawberry/types/fields/resolver.py

View check run for this annotation

Codecov / codecov/patch

strawberry/types/fields/resolver.py#L177

Added line #L177 was not covered by tests
else:
iscoroutinefunction = asyncio.iscoroutinefunction


class StrawberryResolver(Generic[T]):
RESERVED_PARAMSPEC: Tuple[ReservedParameterSpecification, ...] = (
Expand Down Expand Up @@ -345,10 +351,6 @@ def is_graphql_generic(self) -> bool:

@cached_property
def is_async(self) -> bool:
if hasattr(inspect, "markcoroutinefunction"):
iscoroutinefunction = inspect.iscoroutinefunction
else:
iscoroutinefunction = asyncio.iscoroutinefunction
return iscoroutinefunction(self._unbound_wrapped_func) or isasyncgenfunction(
self._unbound_wrapped_func
)
Expand Down

0 comments on commit d4ed01d

Please sign in to comment.