Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.

docs: clarify maxNumberAttempts as total attempts (#3846)

authored by

Yukihiro Hasegawa and committed by
GitHub
00d66fce 6d95675b

+5 -5
+1 -1
docs/advanced/retry-operations.md
··· 60 60 61 61 Talking about increasing the `delay` randomly, `randomDelay` allows us to disable this. When this option is set to `false` we'll only increase the time between attempts with the `initialDelayMs`. This means if we fail the first time we'll have 1 second wait, next fail we'll have 2 seconds and so on. 62 62 63 - We can declare how many times it should attempt the `operation` with `maxNumberAttempts`, otherwise, it defaults to 2. If you want it to retry indefinitely, you can simply pass in `Number.POSITIVE_INFINITY`. 63 + We can declare the maximum number of attempts (including the initial request) with `maxNumberAttempts`, otherwise, it defaults to 2 (which means one retry). If you want it to retry indefinitely, you can simply pass in `Number.POSITIVE_INFINITY`. 64 64 65 65 [For more information on the available options check out the API Docs.](../api/retry-exchange.md) 66 66
+1 -1
docs/api/retry-exchange.md
··· 24 24 | `initialDelayMs` | Specify at what interval the `retrying` should start, this means that if we specify `1000` that when our `operation` fails we'll wait 1 second and then retry it. | 25 25 | `maxDelayMs` | The maximum delay between retries. The `retryExchange` will keep increasing the time between retries so that the server doesn't receive simultaneous requests it can't complete. This time between requests will increase with a random `back-off` factor applied to the `initialDelayMs`, read more about the [thundering herd problem](https://en.wikipedia.org/wiki/Thundering_herd_problem). | 26 26 | `randomDelay` | Allows the randomized delay described above to be disabled. When this option is set to `false` there will be exactly a `initialDelayMs` wait between each retry. | 27 - | `maxNumberAttempts` | Allows the max number of retries to be defined. | 27 + | `maxNumberAttempts` | Defines the maximum number of attempts (including the initial request). For example, `2` means one retry after the initial attempt. | 28 28 | `retryIf` | Apply a custom test to the returned error to determine whether it should be retried. | 29 29 | `retryWith` | Apply a transform function allowing you to selectively replace a retried `Operation` or return a nullish value. This will act like `retryIf` where a truthy value retries (`retryIf` takes precedence and overrides this function.) |
+3 -3
exchanges/retry/src/retryExchange.ts
··· 45 45 * @defaultValue `true` - enables random exponential backoff 46 46 */ 47 47 randomDelay?: boolean; 48 - /** Specifies the maximum times an operation should be sent to the API. 48 + /** Specifies the maximum number of attempts, including the initial request. 49 49 * 50 50 * @remarks 51 - * `maxNumberAttempts` defines the number of attempts an operation should 52 - * be retried until it's considered failed. 51 + * `maxNumberAttempts` defines the total number of attempts before it's 52 + * considered failed. 53 53 * 54 54 * @defaultValue `2` - Retry once, i.e. two attempts 55 55 */