graphql/dataloader

[QUESTION] Is possible chain two dataloaders?

Ouverte

#229 ouverte le 20 nov. 2019

 (1 commentaire) (3 réactions) (0 personne assignée)JavaScript (556 forks)batch import
help wanted

Métriques du dépôt

Stars
 (12 520 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

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);
}

Guide contributeur