Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shmoon-kr authored and patrick91 committed Aug 20, 2024
1 parent 7fd9509 commit 18e8603
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
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 18e8603

Please sign in to comment.