Skip to content

Dataloader return as async Fetcher #51

@dailinyi

Description

@dailinyi

My dataFetcher have some business logic, so need async.
How to use dataloader return some base data.
eg:
BuildWiring is :

RuntimeWiring.newRuntimeWiring()
                .type(newTypeWiring("Query")
                        .dataFetcher("bookById", AsyncDataFetcher.async(graphQLDataFetchers.getBookByIdDataFetcher(), pool)))
                .type(newTypeWiring("Book")
                        .dataFetcher("author", async(graphQLDataFetchers.getAuthorDataFetcher(), pool)))
                .build();

Fetcher.java is:

...
 DataLoader<Object, Object> characters = dataFetchingEnvironment.getDataLoader("books");
CompletableFuture<Object> book = characters.load(bookId);
return book;

The root cause is the result is CompletableFuture<CompletableFuture < Object > >, but graphql only parsing a .get() method;

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