From 1f5e0833dbaf2c7621159386616e18073860f3d0 Mon Sep 17 00:00:00 2001 From: k00b Date: Thu, 3 Apr 2025 11:28:36 -0500 Subject: [PATCH] only use apollo retries if the operation is a query --- lib/apollo.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/apollo.js b/lib/apollo.js index c95af0af..cc4aad54 100644 --- a/lib/apollo.js +++ b/lib/apollo.js @@ -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) } } })