npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dataloader-ai

v0.9.2

Published

Telemetry and tuning for GraphQL DataLoaders

Readme

dataloader-ai

Telemetry and tuning for GraphQL DataLoaders. A drop-in wrapper for the dataloader npm package.

Works out of the box — no API key, no account, no data leaves your machine.

Install

npm install dataloader-ai

Quick start

import { DataLoaderAI } from 'dataloader-ai'

const userLoader = new DataLoaderAI(batchLoadUsers, {
  name: 'user',
})

const user = await userLoader.load(userId)

That's it. You'll see live metrics in your terminal every 5 seconds:

▲ dataloader-ai 14:23:01
──────────────────────────────────────────────────
user
  cache [████████████░░░░░░░░░░░░░] 48.2%
  avg=12.4ms p95=18.1ms batched=184 avoided=42 savings=$0.0042
  batch efficiency ▄▄█▄█▄█▄█▄█▄▄
  recommendation ↑ increase 10 → 12

──────────────────────────────────────────────────

No API key required. No account needed. No data sent anywhere.

Cloud dashboard (optional)

Want a hosted dashboard with AI-powered insights?

export DL_API_KEY=your-key-here

Get a free key: dataloader-ai.com

With a key, telemetry is sent to your dashboard automatically. The dashboard includes:

  • Real-time loader metrics with 5s auto-refresh
  • Per-loader cache hit rates, latency breakdowns, and batch efficiency
  • AI Insights — actionable analysis of your DataLoader performance, powered by piko
  • Batch size recommendations with one-click apply

Dashboard: api.dataloader-ai.com/dashboard

Terminal output continues either way.

What it tracks

  • batch size per flush
  • average and p95 batch latency
  • cache hits and misses per loader
  • batch-size recommendations based on observed latency
  • estimated cost savings from cache hits and batching

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | name | string | 'default' | Loader name shown in terminal and dashboard | | terminal.enabled | boolean | true | Set false to disable terminal output | | terminal.logIntervalMs | number | 5000 | How often to print metrics to terminal | | terminal.color | boolean | true | ANSI color output | | agent.enabled | boolean | true | Set false to disable cloud telemetry | | agent.endpoint | string | https://api.dataloader-ai.com | Dashboard API ingest URL | | agent.apiKey | string | DL_API_KEY env | Your API key | | agent.flushIntervalMs | number | 5000 | How often to flush buffered events | | agent.maxBufferSize | number | 100 | Flush early when buffer reaches this size | | agent.maxRetries | number | 3 | Retry attempts on network failure | | agent.fetchTimeoutMs | number | 5000 | HTTP request timeout | | agent.heartbeatIntervalMs | number | 30000 | How often to send a heartbeat to the API | | optimizer.targetLatencyMs | number | 50 | Latency target the optimizer aims for | | optimizer.minBatchSize | number | 1 | Floor for batch size | | optimizer.maxBatchSize | number | 1000 | Ceiling for batch size | | optimizer.windowSize | number | 20 | Moving average window for latency | | optimizer.onBatchSizeChange | function | — | Callback when batch size adjusts |

Environment variables

| Variable | Description | |----------|-------------| | DL_API_KEY | API key for the cloud dashboard (optional) | | DL_ENDPOINT | Override the ingest endpoint (default: https://api.dataloader-ai.com) | | DL_ENV | Set to development or test to skip heartbeats |

Disable terminal output

const loader = new DataLoaderAI(batchFn, {
  name: 'user',
  terminal: { enabled: false },
})

Batch size change callback

const loader = new DataLoaderAI(batchFn, {
  name: 'user',
  optimizer: {
    onBatchSizeChange: (oldSize, newSize, reason) => {
      console.log(`[dataloader-ai] ${oldSize} → ${newSize}: ${reason}`)
    },
  },
})

Programmatic metrics

const metrics = loader.getMetrics()
console.log(metrics.cacheHitRate, metrics.avgLatencyMs)

Apollo Server example

See examples/apollo-server/.

Architecture

your GraphQL resolver
│ .load(key)
▼
DataLoaderAI (this package)
├── wraps batch fn → records latency
├── instrumented cache map → records cache hits/misses
├── BatchSizeOptimizer → recommends batch-size changes
├── TerminalReporter → prints metrics to stdout (always)
└── MetricsAgent → flushes events to cloud API (if key set)
│
▼ (optional) POST /ingest
dataloader-ai dashboard API

License

MIT — built on the dataloader library by Meta (MIT).