graphql/dataloader

[QUESTION] Is possible chain two dataloaders?

オープン

#229 opened on 2019/11/20

 (1 件のコメント) (3 件のリアクション) (0 人の担当者)JavaScript (556 件のフォーク)batch import
help wanted

Repository metrics

Stars
 (12,520 個のスター)
PR merge metrics
 (PR metrics pending)

説明

Hi, is it possible chain two dataloaders? I have one resolver where I need using two dataloaders, is it possible? I can't use SQL join because it's slow.

async (row, _, { dataSources }) => {
    const partialData = await dataloader1(dataSources).load(row.id);
    if (partialData === null) {
        return null;
    }
    return await dataloader2(dataSources).load(partialData.id);
}

コントリビューターガイド