Skip to content
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: support for fields using async only extensions #444

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions strawberry_django/fields/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ def is_basic_field(self) -> bool:
"""
return False

@functools.cached_property
def is_async(self) -> bool:
# Our default resolver is sync by default but will return a coroutine
# when running ASGI. If we happen to have an extension that only supports
# async, make sure we mark the field as async as well to support resolving
# it properly.
return super().is_async or any(
e.supports_async and not e.supports_sync for e in self.extensions
)

@functools.cached_property
def django_type(self) -> type[WithStrawberryDjangoObjectDefinition] | None:
origin = self.type
Expand Down
1 change: 0 additions & 1 deletion tests/relay/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def test_query_node():
}


@pytest.mark.skip(reason="Async permissions not currently working...")
async def test_query_node_with_async_permissions():
result = await schema.execute(
"""
Expand Down
Loading