Gathering detailed insights and metrics for http-link-dataloader
Gathering detailed insights and metrics for http-link-dataloader
Gathering detailed insights and metrics for http-link-dataloader
Gathering detailed insights and metrics for http-link-dataloader
batched-graphql-request
[](https://badge.fury.io/js/http-link-dataloader)
@npmteam2024/nesciunt-tempore-occaecati
A simple cache system for a single user request, built on the same concepts of [data loader](https://github.com/facebook/dataloader).
📚📡 HTTP Apollo Link with batching & caching provided by dataloader.
npm install http-link-dataloader
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
77 Stars
118 Commits
13 Forks
5 Watchers
10 Branches
7 Contributors
Updated on Jul 30, 2024
Latest Version
0.1.6
Package Id
http-link-dataloader@0.1.6
Size
9.00 kB
NPM Version
6.3.0
Node Version
10.4.0
Published on
Oct 24, 2018
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
???????? HTTP Apollo Link with batching & caching provided by dataloader.
A Apollo Link that batches requests both in Node and the Browser.
You may ask what's the difference to apollo-link-batch-http.
Instead of having a time-frame/fixed cache size based batching approach like in apollo-link-batch-http
, this library uses dataloader for batching requests. It is a more generic approach just depending on the Node.JS event loop that batches all consecutive queries directly.
The main use-case for this library is the usage from a graphql-yoga
server using prisma-binding
, but it can be used in any environment, even the browser as the latest dataloader
version also runs in browser environments.
1import { HTTPLinkDataloader } from 'http-link-dataloader' 2 3const link = new HTTPLinkDataloader() 4 5const token = 'Auth Token' 6 7const httpLink = new HTTPLinkDataloader({ 8 uri: `api endpoint`, 9 headers: { Authorization: `Bearer ${token}` }, 10})
Note that the dataloader cache aggressively caches everything! That means if you don't want to cache anymore, just create a new instance of BatchedHTTPLink
.
A good fit for this is every incoming HTTP request in a server environment - on each new HTTP request a new BatchedHTTPLink
instance is created.
This library uses array-based batching. Querying 2 queries like this creates the following payload:
1query { 2 Item(id: "1") { 3 id 4 name 5 text 6 } 7}
1query { 2 Item(id: "2") { 3 id 4 name 5 text 6 } 7}
Instead of sending 2 separate http requests, it gets combined into one:
1;[ 2 { 3 query: `query { 4 Item(id: "1") { 5 id 6 name 7 text 8 } 9 }`, 10 }, 11 { 12 query: `query { 13 Item(id: "2") { 14 id 15 name 16 text 17 } 18 }`, 19 }, 20]
Note that the GraphQL Server needs to support the array-based batching! (Prisma supports this out of the box)
A batching that would even be faster is alias-based batching. Instead of creating the array described above, it would generate something like this:
1{ 2 query: ` 3 query { 4 item_1: Item(id: "1") { 5 id 6 name 7 text 8 } 9 item_2: Item(id: "2") { 10 id 11 name 12 text 13 } 14 }` 15}
This requires a lot more logic and resolution magic for aliases, but would be a lot faster than the array based batching as our tests have shown! Anyone intersted in working on this is more than welcome to do so! You can either create an issue or just reach out to us in slack and join our #contributors channel.
Join our Slack community if you run into issues or have questions. We love talking to you!
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/23 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
60 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More