{"id":13727391,"url":"https://github.com/prisma-labs/http-link-dataloader","last_synced_at":"2026-04-02T17:10:57.589Z","repository":{"id":29018401,"uuid":"110677087","full_name":"prisma-labs/http-link-dataloader","owner":"prisma-labs","description":"📚📡 HTTP Apollo Link with batching \u0026 caching provided by dataloader.","archived":false,"fork":false,"pushed_at":"2022-12-06T19:51:49.000Z","size":335,"stargazers_count":76,"open_issues_count":15,"forks_count":13,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-10-02T09:29:13.540Z","etag":null,"topics":["apollo-link","batch-request","dataloader","graphql"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prisma-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-14T10:39:28.000Z","updated_at":"2025-08-24T17:58:32.000Z","dependencies_parsed_at":"2023-01-14T13:58:03.435Z","dependency_job_id":null,"html_url":"https://github.com/prisma-labs/http-link-dataloader","commit_stats":null,"previous_names":["prisma/http-link-dataloader","graphcool/batched-graphql-request","graphcool/http-link-dataloader"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/prisma-labs/http-link-dataloader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma-labs%2Fhttp-link-dataloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma-labs%2Fhttp-link-dataloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma-labs%2Fhttp-link-dataloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma-labs%2Fhttp-link-dataloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prisma-labs","download_url":"https://codeload.github.com/prisma-labs/http-link-dataloader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma-labs%2Fhttp-link-dataloader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31311266,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apollo-link","batch-request","dataloader","graphql"],"created_at":"2024-08-03T01:03:53.293Z","updated_at":"2026-04-02T17:10:57.569Z","avatar_url":"https://github.com/prisma-labs.png","language":"TypeScript","readme":"# http-link-dataloader\n\n[![CircleCI](https://circleci.com/gh/prisma/http-link-dataloader.svg?style=shield)](https://circleci.com/gh/prisma/http-link-dataloader) [![npm version](https://badge.fury.io/js/http-link-dataloader.svg)](https://badge.fury.io/js/http-link-dataloader)\n\n📚📡 HTTP Apollo Link with batching \u0026 caching provided by dataloader.\n\n## Idea\n\nA Apollo Link that batches requests both in Node and the Browser.\nYou may ask what's the difference to [apollo-link-batch-http](https://github.com/apollographql/apollo-link/tree/master/packages/apollo-link-batch-http).\nInstead of having a time-frame/fixed cache size based batching approach like in `apollo-link-batch-http`, this library uses [dataloader](https://github.com/facebook/dataloader) for batching requests. It is a more generic approach just depending on the Node.JS event loop that batches all consecutive queries directly.\nThe main use-case for this library is the usage from a [`graphql-yoga`](https://github.com/graphcool/graphql-yoga) server using [`prisma-binding`](https://github.com/graphcool/prisma-binding), but it can be used in any environment, even the browser as the latest `dataloader` version also runs in browser environments.\n\n## Usage\n\n```ts\nimport { HTTPLinkDataloader } from 'http-link-dataloader'\n\nconst link = new HTTPLinkDataloader()\n\nconst token = 'Auth Token'\n\nconst httpLink = new HTTPLinkDataloader({\n  uri: `api endpoint`,\n  headers: { Authorization: `Bearer ${token}` },\n})\n```\n\n## Caching behavior\n\nNote that the dataloader cache aggressively caches everything! That means if you don't want to cache anymore, just create a new instance of `BatchedHTTPLink`.\nA good fit for this is every incoming HTTP request in a server environment - on each new HTTP request a new `BatchedHTTPLink` instance is created.\n\n## Batching\n\nThis library uses array-based batching. Querying 2 queries like this creates the following payload:\n\n```graphql\nquery {\n  Item(id: \"1\") {\n    id\n    name\n    text\n  }\n}\n```\n\n```graphql\nquery {\n  Item(id: \"2\") {\n    id\n    name\n    text\n  }\n}\n```\n\nInstead of sending 2 separate http requests, it gets combined into one:\n\n```js\n;[\n  {\n    query: `query {\n      Item(id: \"1\") {\n        id\n        name\n        text\n      }\n    }`,\n  },\n  {\n    query: `query {\n      Item(id: \"2\") {\n        id\n        name\n        text\n      }\n    }`,\n  },\n]\n```\n\n**Note that the GraphQL Server needs to support the array-based batching!**\n(Prisma supports this out of the box)\n\n## Even better batching\n\nA batching that would even be faster is alias-based batching. Instead of creating the array described above, it would generate something like this:\n\n```js\n{\n  query: `\n    query {\n      item_1: Item(id: \"1\") {\n        id\n        name\n        text\n      }\n      item_2: Item(id: \"2\") {\n        id\n        name\n        text\n      }\n    }`\n}\n```\n\nThis 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!\nAnyone intersted in working on this is more than welcome to do so!\nYou can either create an issue or just reach out to us in slack and join our #contributors channel.\n\n## Help \u0026 Community [![Slack Status](https://slack.prisma.io/badge.svg)](https://slack.prisma.io)\n\nJoin our [Slack community](http://slack.prisma.io) if you run into issues or have questions. We love talking to you!\n\n![](http://i.imgur.com/5RHR6Ku.png)\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma-labs%2Fhttp-link-dataloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprisma-labs%2Fhttp-link-dataloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma-labs%2Fhttp-link-dataloader/lists"}