Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jaw9c committed May 5, 2023
1 parent c501fdb commit 58b92e6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions graphene_django/filter/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ def filter_kwargs():
qs = super().resolve_queryset(connection, iterable, info, args)

if info.is_awaitable(qs):

async def filter_async(qs):
filterset = filterset_class(
data=filter_kwargs(), queryset=await qs, request=info.context
)
if await sync_to_async(filterset.is_valid)():
return filterset.qs
raise ValidationError(filterset.form.errors.as_json())

return filter_async(qs)

filterset = filterset_class(
Expand Down
6 changes: 4 additions & 2 deletions graphene_django/rest_framework/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,19 @@ def mutate_and_get_payload(cls, root, info, **input):
kwargs = cls.get_serializer_kwargs(root, info, **input)
serializer = cls._meta.serializer_class(**kwargs)

try:
try:
get_running_loop()
except RuntimeError:
pass
pass
else:

async def perform_mutate_async():
if await sync_to_async(serializer.is_valid)():
return await sync_to_async(cls.perform_mutate)(serializer, info)
else:
errors = ErrorType.from_errors(serializer.errors)
return cls(errors=errors)

return perform_mutate_async()

if serializer.is_valid():
Expand Down
5 changes: 3 additions & 2 deletions graphene_django/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,15 @@ def get_queryset(cls, queryset, info):
def get_node(cls, info, id):
queryset = cls.get_queryset(cls._meta.model.objects, info)
try:
try:
try:
import asyncio

asyncio.get_running_loop()
except RuntimeError:
pass
else:
return queryset.aget(pk=id)

return queryset.get(pk=id)
except cls._meta.model.DoesNotExist:
return None
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"pytz",
"django-filter>=22.1",
"pytest-django>=4.5.2",
"pytest-asyncio>=0.16,<2"
"pytest-asyncio>=0.16,<2",
] + rest_framework_require


Expand Down

0 comments on commit 58b92e6

Please sign in to comment.