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

apollo-link-retry

Package Overview
Dependencies
Maintainers
3
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-link-retry

Retry Apollo Link for GraphQL Network Stack

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

Purpose

An Apollo Link to allow multiple attempts when an operation has failed. One such use case is to try a request while a network connection is offline and retry until it comes back online. You can configure a RetryLink to vary the number of times it retries and how long it waits between retries through its configuration.

Installation

npm install apollo-link-retry --save

Usage

import { RetryLink } from "apollo-link-retry";

const link = new RetryLink();

Options

Retry Link takes an object with three options on it to customize the behavior of the link.

Retry Link retries on network errors only, not on GraphQL errors.

The default delay algorithm is to wait delay ms between each retry. You can customize the algorithm (eg, replacing with exponential backoff) with the interval option. The possible values for the configuration object are as follow:

  • max: a number or function matching (Operation => number) to determine the max number of times to try a single operation before giving up. It defaults to 10
  • delay: a number or function matching (Operation => number) to input to the interval function below: Defaults to 300 ms
  • interval: a function matching (delay: number, count: number) => number which is the amount of time (in ms) to wait before the next attempt; count is the number of requests previously tried
import { RetryLink } from "apollo-link-retry";

const max = (operation) => operation.getContext().max;
const delay = 5000;
const interval = (delay, count) => {
  if (count > 5) return 10000;
  return delay;
}

const link = new RetryLink({
  max,
  delay,
  interval
});

Context

The Retry Link does not use the context for anything.

FAQs

Package last updated on 30 Nov 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