Skip to content

Kotlin coroutine suspend fun resolver hangs when awaiting a data loader #419

Open
@arian

Description

@arian

We're using java-graphql batch loaders (https://www.graphql-java.com/documentation/v15/batching/)

Instead of returning CompletableFutures in our resolver methods, I tried using kotlin suspend functions, like this:

    suspend fun loadUsers(env: DataFetchingEnvironment): List<UserGQL> {
        val users = Context.getDataLoaders(env)
            .usersLoader
            .loadMany(listOf(1, 2, 3))
            .await()
        return users.map { UserGQL(it) } 
    }

However it seems to be hanging on the await. I think it's blocking there, before java-graphql called the dispatch on the registered data loaders (in DataLoaderRegistry).

What would be the best way to solve this? I couldn't really find examples in the documentation or the original pull request (#201)

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