Skip to content
JM.
All posts

graphql · nodejs · performance

GraphQL N+1, actually solved

2026.07.30 · 1 min read · Jeet Mendpara

DUMMY CONTENT. Replace before launch. Target 1100 words.

Placeholder opening.

The problem, concretely

Placeholder.

const userLoader = new DataLoader<string, User>(async (ids) => {
  const users = await db.user.findMany({ where: { id: { in: [...ids] } } });
  const byId = new Map(users.map((u) => [u.id, u]));
  return ids.map((id) => byId.get(id) ?? new Error(`No user ${id}`));
});

The mistake everyone makes

Placeholder — a module-scoped loader caches across requests and leaks data between users.

Getting the ordering right

Placeholder.

Verifying it worked

Placeholder.