All Projects â†’ prisma-labs â†’ http-link-dataloader

prisma-labs / http-link-dataloader

Licence: MIT License
📚📡 HTTP Apollo Link with batching & caching provided by dataloader.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to http-link-dataloader

apollo-link-defer
Interface for creating asynchronous links.
Stars: ✭ 16 (-80%)
Mutual labels:  apollo-link
apollo-link-logger
A logger for Apollo Link that resembles redux-logger
Stars: ✭ 161 (+101.25%)
Mutual labels:  apollo-link
triplet-loss-pytorch
A generic triplet data loader for image classification problems,and a triplet loss net demo.
Stars: ✭ 70 (-12.5%)
Mutual labels:  dataloader
laika
Log, test, intercept and modify Apollo Client's operations
Stars: ✭ 99 (+23.75%)
Mutual labels:  apollo-link
dataloader
Dataloader is a generic utility for batch data loading with caching, works great with GraphQL
Stars: ✭ 114 (+42.5%)
Mutual labels:  dataloader
postloader
A scaffolding tool for projects using DataLoader, Flow and PostgreSQL.
Stars: ✭ 52 (-35%)
Mutual labels:  dataloader
PyTorch-LMDB
Scripts to work with LMDB + PyTorch for Imagenet training
Stars: ✭ 49 (-38.75%)
Mutual labels:  dataloader
tanka-graphql
GraphQL server and execution libraries
Stars: ✭ 57 (-28.75%)
Mutual labels:  apollo-link
graphql-spotify
GraphQL Schema And Resolvers For Spotify Web API
Stars: ✭ 55 (-31.25%)
Mutual labels:  dataloader
UtterancePIT-Speech-Separation
According to funcwj's uPIT, the training code supporting multi-gpu is written, and the Dataloader is reconstructed.
Stars: ✭ 55 (-31.25%)
Mutual labels:  dataloader
apollo-link-fragment-argument
An Apollo Link to enable to parameterize fragments
Stars: ✭ 35 (-56.25%)
Mutual labels:  apollo-link
graphql-modules-app
TypeScripted Apollo GraphQL Server using modules and a NextJS frontend utilising React modules with Apollo hooks. All bundled with a lot of dev friendly tools in a lerna setup..
Stars: ✭ 39 (-51.25%)
Mutual labels:  dataloader
wp-graphql
WordPress REST API exposed via GraphQL
Stars: ✭ 59 (-26.25%)
Mutual labels:  dataloader
SFDX-Data-Move-Utility-Desktop-App
This repository contains the special Desktop GUI Application, that will help you to prepare and execute data migration packages using the SFDMU Plugin.
Stars: ✭ 65 (-18.75%)
Mutual labels:  dataloader
apollo-link-tracer
Trace your apollo queries and mutations with https://github.com/apollographql/apollo-link
Stars: ✭ 20 (-75%)
Mutual labels:  apollo-link
MobilePose
Light-weight Single Person Pose Estimator
Stars: ✭ 588 (+635%)
Mutual labels:  dataloader
apollo-link-segment
Automatic analytics for Apollo Apps.
Stars: ✭ 18 (-77.5%)
Mutual labels:  apollo-link
pymia
pymia: A Python package for data handling and evaluation in deep learning-based medical image analysis
Stars: ✭ 46 (-42.5%)
Mutual labels:  dataloader
workers-graphql-gateway-example
GraphQL running on Cloudflare Workers
Stars: ✭ 68 (-15%)
Mutual labels:  dataloader
Tensorflow-data-loader
Reading data into tensorflow using tf.data function
Stars: ✭ 15 (-81.25%)
Mutual labels:  dataloader

http-link-dataloader

CircleCI npm version

📚📡 HTTP Apollo Link with batching & caching provided by dataloader.

Idea

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.

Usage

import { HTTPLinkDataloader } from 'http-link-dataloader'

const link = new HTTPLinkDataloader()

const token = 'Auth Token'

const httpLink = new HTTPLinkDataloader({
  uri: `api endpoint`,
  headers: { Authorization: `Bearer ${token}` },
})

Caching behavior

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.

Batching

This library uses array-based batching. Querying 2 queries like this creates the following payload:

query {
  Item(id: "1") {
    id
    name
    text
  }
}
query {
  Item(id: "2") {
    id
    name
    text
  }
}

Instead of sending 2 separate http requests, it gets combined into one:

;[
  {
    query: `query {
      Item(id: "1") {
        id
        name
        text
      }
    }`,
  },
  {
    query: `query {
      Item(id: "2") {
        id
        name
        text
      }
    }`,
  },
]

Note that the GraphQL Server needs to support the array-based batching! (Prisma supports this out of the box)

Even better batching

A batching that would even be faster is alias-based batching. Instead of creating the array described above, it would generate something like this:

{
  query: `
    query {
      item_1: Item(id: "1") {
        id
        name
        text
      }
      item_2: Item(id: "2") {
        id
        name
        text
      }
    }`
}

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.

Help & Community Slack Status

Join our Slack community if you run into issues or have questions. We love talking to you!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].