
Product
Introducing Socket MCP for Claude Desktop
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
A promise batching utility mostly used in GraphQL resolvers to avoid N + 1 data fetching.
A promise batching utility mostly used in GraphQL resolvers to avoid N + 1 data fetching
npm add next-batch
import { nextBatch } from "next-batch";
// in your resolvers
User: {
tasks: async ({ id: userId }, _args, context) => {
// batch to collect all resolver requests that are flushed
// in the next execution frame using process.nextTick()
const tasksBatch = nextBatch({
// unique string key to collect all promises into a single batch
key: "tasks",
// batchHandler is the callback that will be invoked when the batch
// is flushed in the next tick. All keys from taskBatch.add(key)
// will be collected as an array and sent as an argument to this
// batchHandler callback
batchHandler: async (keys: { id: number }[]) => {
const tasks = await taskDB.findByUserIds({
ids: keys.map((key) => key.id),
});
// batch handler should return a Map with every key in keys arg
// and its corresponding value as a map entry.
// remember to use the same key reference and don't deconstruct
// and construct a new object as map key
const result = new Map<typeof keys[number], { title: string }>();
keys.forEach((key) => {
const task = tasks.filter((task) => task.id === key.id);
result.set(key, task);
});
return result;
},
});
// tasks are requested per user but resolved in batch for all users
// via the JavaScript magic of our next-batch util
const tasks = await tasksBatch.add({ id: userId });
return tasks;
};
}
MIT © Dinesh Pandiyan
FAQs
A promise batching utility mostly used in GraphQL resolvers to avoid N + 1 data fetching.
The npm package next-batch receives a total of 0 weekly downloads. As such, next-batch popularity was classified as not popular.
We found that next-batch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.