
Security News
Insecure Agents Podcast: Certified Patches, Supply Chain Security, and AI Agents
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.
batched-graphql-request
Advanced tools
[](https://badge.fury.io/js/http-link-dataloader)
The idea of this library is to provide query batching and caching for Node.js backends on a per-request basis. That means, per http request to your Node.js backend, you create a new instance of BatchedGraphQLClient which has its own cache and batching. Sharing a BatchedGraphQLClient instance across requests against your webserver is not recommended as that would result in Memory Leaks with the Cache growing infinitely. The batching and caching is based on dataloader
npm install batched-graphql-request
In this example, we proxy requests that come in the form of batched array. Instead of sending each request individually to my-endpoint, all requests are again batched together and send grouped to the underlying endpoint, which increases the performance dramatically.
import { BatchedGraphQLClient } from 'batched-graphql-request'
import * as express from 'express'
import * as bodyParser from 'body-parser'
const app = express()
/*
This accepts POST requests to /graphql of this form:
[
{query: "...", variables: {}},
{query: "...", variables: {}},
{query: "...", variables: {}}
]
*/
app.use(
'/graphql',
bodyParser.json(),
async (req, res) => {
const client = new BatchedGraphQLClient('my-endpoint', {
headers: {
Authorization: 'Bearer my-jwt-token',
},
})
const requests = Array.isArray(req.body) ? req.body : [req.body]
const results = await Promise.all(requests.map(({query, variables}) => client.request(query, variables)))
res.json(results)
}
)
app.listen(3000, () =>
console.log('Server running.'),
)
To learn more about the usage, please check out graphql-request
FAQs
[](https://badge.fury.io/js/http-link-dataloader)
We found that batched-graphql-request 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.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.

Security News
The planned feature introduces a review step before releases go live, following the Shai-Hulud attacks and a rocky migration off classic tokens that disrupted maintainer workflows.