Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apollo-link-batch-http

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-link-batch-http

Batch HTTP transport layer for GraphQL

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-40.75%
Maintainers
3
Weekly downloads
 
Created
Source

Note: This package will be updated to remove the dependency on apollo-fetch an use the same options / API as the http-link

Purpose

An Apollo Link to allow batching of multiple operations into a single http request. Instead of sending a single operation, it sends an array of operations to the server.

Installation

npm install apollo-link-batch-http --save

Usage

import { BatchHttpLink } from "apollo-link-batch-http";

const link = new BatchHttpLink({ uri: "/graphql" });

Options

Batch HTTP Link takes an object with four options on it to customize the behavior of the link. The possible keys on this configuration object are:

  • uri: a string of the server or a default of "/graphql"
  • batchMax: a max number of items to batch, defaults at 10
  • batchInterval: the interval at which to batch (in ms), defaults to 10
  • fetch: an instance of ApolloFetch

By default, this link uses the Apollo Fetch library for the HTTP transport.

Context

The Batch HTTP Link uses the headers field on the context to allow passing headers to the HTTP request.

  • headers: an object to be converted to headers for the http request
import { BatchHttpLink } from "apollo-link-batch-http";
import ApolloClient from "apollo-client";
import InMemoryCache from "apollo-cache-inmemory";

const client = new ApolloClient({
  link: new BatchHttpLink({ uri: "/graphql" }),
  cache: new InMemoryCache()
});

// a query with apollo-client that will be batched
client.query({
  query: MY_QUERY,
  context: {
    // example of setting the headers with context per operation
    headers: {
      authoriztion: Meteor.userId()
    }
  }
})

FAQs

Package last updated on 08 Dec 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc