INNER CODE UNIT · TypeScript

directLoader

slaypni/type-graphql-dataloader · src/decorators/typeorm/ExplicitLoaderImpl.ts:157

function directLoader<V>(
  relation: RelationMetadata,
  connection: Connection,
  grouper: string | ((entity: V) => any)
) {
  return async (ids: readonly any[]) => {
    const entities = keyBy(
      await connection
        .createQueryBuilder<V>(relation.type, relation.propertyName)
        .whereInIds(ids)
        .getMany(),
      grouper
    ) as Dictionary<V>;
    return ids.map((id) => entities[id]);
  };
}

class ToManyDataloader<V> extends DataLoader<any, V> {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…