only use apollo retries if the operation is a query
This commit is contained in:
parent
2cf0f1d268
commit
1f5e0833db
@ -3,6 +3,7 @@ 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'
|
||||
import { isMutationOperation, isQueryOperation } from '@apollo/client/utilities'
|
||||
function isFirstPage (cursor, existingThings, limit = LIMIT) {
|
||||
if (cursor) {
|
||||
const decursor = decodeCursor(cursor)
|
||||
@ -37,7 +38,8 @@ const retryLink = new RetryLink({
|
||||
attempts: {
|
||||
max: Infinity,
|
||||
retryIf: (error, _operation) => {
|
||||
return !!error
|
||||
// retry only if the error is not a mutation and the operation is a query
|
||||
return !!error && !isMutationOperation(_operation.query) && isQueryOperation(_operation.query)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user