graphql-http-ws-client
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -73,2 +73,3 @@ import { InMemoryCache } from '@apollo/client/cache/cache.cjs'; | ||
createWSLink: true, | ||
createRetryLink: true, | ||
...options | ||
@@ -165,14 +166,19 @@ }; | ||
const retryLink = new RetryLink({ | ||
attempts: { | ||
max: Infinity | ||
} | ||
}); | ||
let retryLink; | ||
if(mergedOptions.createRetryLink) { | ||
retryLink = new RetryLink({ | ||
...mergedOptions.retryLinkOptions | ||
}); | ||
} | ||
const link = concat(retryLink, transportLink); | ||
const links = [transportLink]; | ||
if(retryLink) | ||
links.unshift(retryLink); | ||
if(mergedOptions.middleware) | ||
links.unshift(mergedOptions.middleware); | ||
return { | ||
link: options.hasOwnProperty('middleware') | ||
? concat(options.middleware, link) | ||
: link, | ||
link: concat(...links), | ||
httpLink: httpLink, | ||
@@ -179,0 +185,0 @@ wsLink: wsLink, |
@@ -1222,3 +1222,4 @@ var __create = Object.create; | ||
createHTTPLink: true, | ||
createWSLink: true | ||
createWSLink: true, | ||
createRetryLink: true | ||
}, options); | ||
@@ -1280,10 +1281,13 @@ const httpURLToWS = (url) => { | ||
transportLink = httpLink; | ||
const retryLink = new RetryLink({ | ||
attempts: { | ||
max: Infinity | ||
} | ||
}); | ||
const link = concat(retryLink, transportLink); | ||
let retryLink; | ||
if (mergedOptions.createRetryLink) { | ||
retryLink = new RetryLink(__spreadValues({}, mergedOptions.retryLinkOptions)); | ||
} | ||
const links = [transportLink]; | ||
if (retryLink) | ||
links.unshift(retryLink); | ||
if (mergedOptions.middleware) | ||
links.unshift(mergedOptions.middleware); | ||
return { | ||
link: options.hasOwnProperty("middleware") ? concat(options.middleware, link) : link, | ||
link: concat(...links), | ||
httpLink, | ||
@@ -1290,0 +1294,0 @@ wsLink, |
{ | ||
"name": "graphql-http-ws-client", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
## GraphQL client over HTTP/WS | ||
### Node.js with HTTP and WS links, and context | ||
### Node.js with HTTP and WS links, context, and [retry options](https://www.apollographql.com/docs/react/api/link/apollo-link-retry/) | ||
@@ -27,2 +27,12 @@ import { createGraphQLClient } from "graphql-http-ws-client"; | ||
connectionParams: addContext | ||
}, | ||
retryLinkOptions: { | ||
delay: { | ||
initial: 300, | ||
max: 6000, | ||
jitter: true | ||
}, | ||
attempts: { | ||
max: Infinity | ||
} | ||
} | ||
@@ -130,2 +140,11 @@ }); | ||
#### v3.1 | ||
- Retry Link options supported | ||
- Default retry link config changes to [Apollo link default](https://www.apollographql.com/docs/react/api/link/apollo-link-retry/) (notably, 5 attempts instead of infinte attempts) | ||
#### v3.0 | ||
- Exports ES6 and CJS versions | ||
#### v2.0 | ||
@@ -132,0 +151,0 @@ |
@@ -17,2 +17,3 @@ import { getMainDefinition } from "@apollo/client/utilities/utilities.cjs"; | ||
createWSLink: true, | ||
createRetryLink: true, | ||
...options | ||
@@ -109,14 +110,19 @@ }; | ||
const retryLink = new RetryLink({ | ||
attempts: { | ||
max: Infinity | ||
} | ||
}); | ||
let retryLink; | ||
if(mergedOptions.createRetryLink) { | ||
retryLink = new RetryLink({ | ||
...mergedOptions.retryLinkOptions | ||
}); | ||
} | ||
const link = concat(retryLink, transportLink); | ||
const links = [transportLink]; | ||
if(retryLink) | ||
links.unshift(retryLink); | ||
if(mergedOptions.middleware) | ||
links.unshift(mergedOptions.middleware); | ||
return { | ||
link: options.hasOwnProperty('middleware') | ||
? concat(options.middleware, link) | ||
: link, | ||
link: concat(...links), | ||
httpLink: httpLink, | ||
@@ -123,0 +129,0 @@ wsLink: wsLink, |
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
117792
3013
163