apollo-link-retry
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -69,3 +69,3 @@ (function (global, factory) { | ||
exports['default'] = RetryLink; | ||
exports.RetryLink = RetryLink; | ||
@@ -72,0 +72,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
import { ApolloLink, Observable, Operation, NextLink, FetchResult } from 'apollo-link'; | ||
export declare type ParamFnOrNumber = (operation: Operation) => number | number; | ||
export default class RetryLink extends ApolloLink { | ||
export declare class RetryLink extends ApolloLink { | ||
private delay; | ||
@@ -5,0 +5,0 @@ private max; |
@@ -63,3 +63,3 @@ var __extends = (this && this.__extends) || (function () { | ||
}(ApolloLink)); | ||
export default RetryLink; | ||
export { RetryLink }; | ||
//# sourceMappingURL=retryLink.js.map |
{ | ||
"name": "apollo-link-retry", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "Retry Apollo Link for GraphQL Network Stack", | ||
@@ -43,10 +43,11 @@ "author": "Evans Hauser <evanshauser@gmail.com>", | ||
"peerDependencies": { | ||
"apollo-link": "^0.7.0" | ||
"apollo-link": "^0.8.0" | ||
}, | ||
"devDependencies": { | ||
"@types/graphql": "0.11.4", | ||
"@types/jest": "21.1.1", | ||
"apollo-link": "^0.7.0", | ||
"@types/graphql": "0.11.5", | ||
"@types/jest": "21.1.2", | ||
"@types/zen-observable": "^0.5.3", | ||
"apollo-link": "^0.8.0", | ||
"browserify": "14.4.0", | ||
"graphql": "0.11.6", | ||
"graphql": "0.11.7", | ||
"graphql-tag": "2.4.2", | ||
@@ -56,3 +57,3 @@ "jest": "21.2.1", | ||
"rollup": "0.45.2", | ||
"ts-jest": "21.0.1", | ||
"ts-jest": "21.1.2", | ||
"tslint": "5.7.0", | ||
@@ -59,0 +60,0 @@ "typescript": "2.5.1", |
# Retry Link | ||
## 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. Retry's can vary based on operation through the configuration of the link. | ||
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. | ||
@@ -12,3 +12,3 @@ ## Installation | ||
```js | ||
import RetryLink from "apollo-link-retry"; | ||
import { RetryLink } from "apollo-link-retry"; | ||
@@ -19,16 +19,20 @@ const link = new RetryLink(); | ||
## Options | ||
Retry Link takes an object with three options on it to customize the behavoir of the link. | ||
Retry Link takes an object with three options on it to customize the behavior of the link. | ||
|name|value|default|required| | ||
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. | ||
|name|value|default|meaning| | ||
|---|---|---|---| | ||
|max|number or Operation => number|10|false| | ||
|delay|number or Operation => number|300|false| | ||
|interval|(delay: number, count: number) => number|delay => delay|false| | ||
|max|number or (Operation => number)|10|max number of times to try a single operation before giving up| | ||
|delay|number or (Operation => number)|300|input 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| | ||
```js | ||
import RetryLink from "apollo-link-retry" | ||
import RetryLink from "apollo-link-retry"; | ||
const max = (operation) => operation.getContext().max | ||
const max = (operation) => operation.getContext().max; | ||
const delay = 5000; | ||
const interval = (delay, count) => { | ||
if (count > 5) return 10,000; | ||
if (count > 5) return 10000; | ||
return delay; | ||
@@ -45,2 +49,2 @@ } | ||
## Context | ||
The Retry Link does not use the context for anything | ||
The Retry Link does not use the context for anything. |
import gql from 'graphql-tag'; | ||
import { execute, ApolloLink, Observable, FetchResult } from 'apollo-link'; | ||
import RetryLink from '../retryLink'; | ||
import { RetryLink } from '../retryLink'; | ||
@@ -6,0 +6,0 @@ const query = gql` |
@@ -7,3 +7,2 @@ import { | ||
FetchResult, | ||
ZenObservable, | ||
} from 'apollo-link'; | ||
@@ -18,3 +17,3 @@ | ||
export default class RetryLink extends ApolloLink { | ||
export class RetryLink extends ApolloLink { | ||
private delay: ParamFnOrNumber; | ||
@@ -21,0 +20,0 @@ private max: ParamFnOrNumber; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22864
12
48
14
312