add retry link back
This commit is contained in:
parent
e6081ebef3
commit
bdd87e7d39
@ -1,8 +1,8 @@
|
|||||||
import { ApolloClient, InMemoryCache, HttpLink, makeVar, split } from '@apollo/client'
|
import { ApolloClient, InMemoryCache, HttpLink, makeVar, split, from } from '@apollo/client'
|
||||||
import { BatchHttpLink } from '@apollo/client/link/batch-http'
|
import { BatchHttpLink } from '@apollo/client/link/batch-http'
|
||||||
import { decodeCursor, LIMIT } from './cursor'
|
import { decodeCursor, LIMIT } from './cursor'
|
||||||
import { COMMENTS_LIMIT, SSR } from './constants'
|
import { COMMENTS_LIMIT, SSR } from './constants'
|
||||||
|
import { RetryLink } from '@apollo/client/link/retry'
|
||||||
function isFirstPage (cursor, existingThings, limit = LIMIT) {
|
function isFirstPage (cursor, existingThings, limit = LIMIT) {
|
||||||
if (cursor) {
|
if (cursor) {
|
||||||
const decursor = decodeCursor(cursor)
|
const decursor = decodeCursor(cursor)
|
||||||
@ -28,13 +28,30 @@ export default function getApolloClient () {
|
|||||||
|
|
||||||
export const meAnonSats = {}
|
export const meAnonSats = {}
|
||||||
|
|
||||||
|
const retryLink = new RetryLink({
|
||||||
|
delay: {
|
||||||
|
initial: 300,
|
||||||
|
max: 30000,
|
||||||
|
jitter: true
|
||||||
|
},
|
||||||
|
attempts: {
|
||||||
|
max: Infinity,
|
||||||
|
retryIf: (error, _operation) => {
|
||||||
|
return !!error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
function getClient (uri) {
|
function getClient (uri) {
|
||||||
const link = split(
|
const link = from([
|
||||||
// batch zaps if wallet is enabled so they can be executed serially in a single request
|
retryLink,
|
||||||
operation => operation.operationName === 'act' && operation.variables.act === 'TIP' && operation.getContext().batch,
|
split(
|
||||||
new BatchHttpLink({ uri, batchInterval: 1000, batchDebounce: true, batchMax: 0, batchKey: op => op.variables.id }),
|
// batch zaps if wallet is enabled so they can be executed serially in a single request
|
||||||
new HttpLink({ uri })
|
operation => operation.operationName === 'act' && operation.variables.act === 'TIP' && operation.getContext().batch,
|
||||||
)
|
new BatchHttpLink({ uri, batchInterval: 1000, batchDebounce: true, batchMax: 0, batchKey: op => op.variables.id }),
|
||||||
|
new HttpLink({ uri })
|
||||||
|
)
|
||||||
|
])
|
||||||
|
|
||||||
return new ApolloClient({
|
return new ApolloClient({
|
||||||
link,
|
link,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user