Is it possible to use AsyncExecutor?
See original GitHub issueHello!
How can I use AsyncExecutor with graphene-django?
I try this setup:
# types.py
class Source(graphene.ObjectType):
value = graphene.String()
# queries.py
class SourcesQuery(graphene.ObjectType):
sources = graphene.List(
of_type=Source
)
async def resolve_sources(self, info):
await asyncio.sleep(0.0001)
return [Source(value='foo'), Source(value='bar')]
# backend.py
class CustomBackend(GraphQLCoreBackend):
def __init__(self, *args, **kwargs):
self.execute_params = {
"executor": AsyncioExecutor(),
"return_promise": False,
}
# urls.py
path("graphql", GraphQLView.as_view(
backend=CustomBackend(),
schema=graphene.Schema(query=SourcesQuery),
)),
But this didn’t work. What is wrong?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Spring Boot Async Executor Management with ... - Medium
Enabling to asynchronous functionality in Spring Boot is very easy with using @EnableAsync annotation over any of Spring Boot configuration ...
Read more >Spring @Async Executor - java - Stack Overflow
Is there anyway to be able to specify different Executors for different classes? Seems a bit constricting to have to use one Executor...
Read more >Spring @Async for Asynchronous Processing
An introduction to the spring @async annotation. Learn how enable asynchronous execution support in Spring with @Async and @EnableAsync ...
Read more >Getting Started | Creating Asynchronous Methods - Spring
Choose either Gradle or Maven and the language you want to use. This guide assumes that you chose Java. Click Dependencies and select...
Read more >How To Do @Async in Spring - Baeldung
In this tutorial, we'll explore the asynchronous execution support in Spring and the @Async annotation. Simply put, annotating a method of a ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why is this closed? There is still no way to use async executor nor resolvers. At least not with provided GraphQLView.
If I understand this question correctly, you are trying to implement asynchronous code within the default Django resolver. This is not supported within Django itself as far as I know.
What we did to resolve asynchronous execution of graphql resolvers / subscriptions is to use the django-channels package in combination with apollo-client.
More info can be found here https://github.com/graphql-python/graphene/issues/430, and this gist https://gist.github.com/tricoder42/af3d0337c1b33d82c1b32d12bd0265ec