Skip to content

Is it possible to use AsyncExecutor? #616

Closed
@artinnok

Description

@artinnok

Hello!

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions