graphql-java / graphql-java/java-dataloader

composing dataloaders

Open
#54 22 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

keep-open
Dominant language
Java
Stars
525
Forks
101
PR merge metrics
No merged PRs in 30d

Description

Hi,

I have a datafetcher where I use 2 dataloaders in sequence: the first to translate from 1 ID to another, the second to fetch data corresponding to the second ID.

loader1.load(id1).thenCompose(id2 -> loader2.load(id2))

This hangs because dispatchAll() is not called again after loader1 completes.
I can work around that by adding that call inside the thenCompose() lambda but then it is called for every id2 which is ugly at the very least.

Is there a better way of doing this?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by tracing the dispatchAll lifecycle for the sequential loader1.load(id1).thenCompose(...) example, then inspect how nested loads are expected to be dispatched. Done means sequential dataloaders complete without hanging and batching does not require a per-id dispatch call.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, java
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.