GraphQL: getting started

Lesson 05 · 12 min

N+1 and DataLoader

Ten books, ten queries for authors. DataLoader makes one.

12 minLesson 5 of 9Practice includedAsk AI on any point

The Book.author resolver runs for each book separately. A list of 50 books is 1 query for books and 50 for authors. DataLoader collects every load(id) within one event loop tick and makes one batch query WHERE id IN (…), and it caches results within the request.

Sign in to continue

The rest of this lesson opens after sign up

The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.