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

  • 0.8.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
79K
increased by6.29%
Maintainers
3
Weekly downloads
 
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.

namevaluedefaultmeaning
maxnumber or (Operation => number)10max number of times to try a single operation before giving up
delaynumber or (Operation => number)300input to the interval function below
interval(delay: number, count: number) => number(delay, count => delay)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 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