extend apollo mutation timeout

1.5k Views Asked by At

I'm running down a rabbit hole so I'm asking my question here.

I have a useMutation mutation that uploads up to 10MB JSON data to my DB. This obviously takes a long time and I received a timeout error which I believed caused the query to run twice which then uploaded some of the data twice.

How can I state for one mutation to have a longer timeout? Where do I specify the timeout? Can I specify it not to be retried?

I am currently using a couple of links:

import { onError } from '@apollo/client/link/error'
import { RetryLink } from '@apollo/client/link/retry'
import { setContext } from '@apollo/client/link/context'

I believe the RetryLink (https://www.apollographql.com/docs/link/links/retry/) may help. Currently I have default settings:


// default settings
const retryLink = new RetryLink({
  delay: {
    initial: 300,
    max: Infinity,
    jitter: true,
  },
  attempts: {
    max: 5,
    retryIf: (error, _operation) => !!error,
  },
})
1

There are 1 best solutions below

0
On

500 level errors are server side issues. In this case, your server is the one indicating that there is a timeout, so there is nothing to do on the client side. You'll have to check your server configuration and figure it out on that end.