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

  • 0.4.0
  • Source
  • npm
  • Socket score

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

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 { BatchLink } from "apollo-link-batch-http";

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

Options

Batch HTTP Link takes an object with four options on it to customize the behavior of the link.

namevaluedefaultrequired
uristring"/graphql"false
batchMaxnumber10false
batchIntervalnumber10false
fetchApolloFetchApolloFetchfalse

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.

namevaluedefaultrequired
headersHeaders (or object){}false
import BatchLink from "apollo-link-batch-http";
import ApolloClient from "apollo-client";
import InMemoryCache from "apollo-cache-inmemory";

const client = new ApolloClient({
  link: new BatchLink({ 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 13 Oct 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