graphene-django
graphene-django copied to clipboard
Add async view
Async view for django >= 3.1
Description
This is still a work in progress, but based on repl from @jkimbo (https://replit.com/@jkimbo/Graphene-async#main/schema.pyhttps://replit.com/@jkimbo/Graphene-async#main/schema.py) I got an async view working for graphene.
I think this should be part of graphene django.
You can use it like this for now
from django.conf.urls import url
from django.views.decorators.csrf import csrf_exempt
from graphene_django.views import AsyncGraphQLView
# ... your django urls
urlpatterns += [ url(r"^graphql$", csrf_exempt(AsyncGraphQLView.as_view(schema=schema, graphiql=True)))]
🖖 any kind of help / review, even at this stage is much appreciated as I am not really experienced with graphene internals, and there might be some area for improvement here. Thanks !
TODO
- [ ] Add examples with async resolvers
- [ ] Add tests
- [ ] Add documentation
Is it possible to mix sync and async resolvers this way?
Is it possible to mix sync and async resolvers this way?
You should be able to using @sync_to_async
decorator.
As I said in the description of the PR, I don't have a strong experience with graphene / async django, but I need it in a specific project, so feel free to try it out with the code from this PR or this repo https://github.com/fabienheureux/graphene-async
I meant if one has 100 sync resolvers already and only wants to add a few async ones, how should one proceed? Even if front-end guarantees to not mix sync and async queries.
@Suor mixing Sync and async resolvers is handled directly by Graphql-Core
, not by the view. So that will work.
What are the next steps on this one? It would be very helpful to have async views with graphene django 🙏🏼
Hey, sorry I have not been using this project since a few months, I am not sure when I will be able to catch up, I hope before the end of 2022 but I am buried under a lot of client work at the moment 😓
Closed in favor of https://github.com/graphql-python/graphene-django/pull/1394