platform/packages/graphql/data_loader
2021-02-14 13:22:25 +08:00
..
example Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
lib Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
test Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
.gitignore Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
analysis_options.yaml Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
CHANGELOG.md Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
LICENSE Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
mono_pkg.yaml Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
pubspec.yaml Updated dart requirements to 2.10 2021-02-14 13:22:25 +08:00
README.md Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00

data_loader

Pub build status

Batch and cache database lookups. Works well with GraphQL. Ported from the original JS version: https://github.com/graphql/dataloader

Installation

In your pubspec.yaml:

dependencies:
  data_loader: ^1.0.0

Usage

Complete example: https://github.com/angel-dart/graphql/blob/master/data_loader/example/main.dart

var userLoader = new DataLoader((key) => myBatchGetUsers(keys));
var invitedBy = await userLoader.load(1)then(user => userLoader.load(user.invitedByID))
print('User 1 was invited by $invitedBy'));