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 { decodeCursor, LIMIT } from './cursor'
|
||||
import { COMMENTS_LIMIT, SSR } from './constants'
|
||||
|
||||
import { RetryLink } from '@apollo/client/link/retry'
|
||||
function isFirstPage (cursor, existingThings, limit = LIMIT) {
|
||||
if (cursor) {
|
||||
const decursor = decodeCursor(cursor)
|
||||
@ -28,13 +28,30 @@ export default function getApolloClient () {
|
||||
|
||||
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) {
|
||||
const link = split(
|
||||
// batch zaps if wallet is enabled so they can be executed serially in a single request
|
||||
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 })
|
||||
)
|
||||
const link = from([
|
||||
retryLink,
|
||||
split(
|
||||
// batch zaps if wallet is enabled so they can be executed serially in a single request
|
||||
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({
|
||||
link,
|
||||
|
Loading…
x
Reference in New Issue
Block a user