Skip to content

Commit

Permalink
Make view async for django.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcraciunoiu committed Jul 17, 2024
1 parent c2d601c commit cc665df
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions graphene_django/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.http.response import HttpResponseBadRequest
from django.shortcuts import render
from django.utils.decorators import classonlymethod, method_decorator
from django.utils.functional import classproperty
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.generic import View
from graphql import (
Expand Down Expand Up @@ -497,6 +498,10 @@ def as_view(cls, **initkwargs):
view._is_coroutine = coroutines._is_coroutine
return view

@classproperty
def view_is_async(cls):
return True

async def dispatch(self, request, *args, **kwargs):
try:
if request.method.lower() not in ("get", "post"):
Expand Down

0 comments on commit cc665df

Please sign in to comment.