diff --git a/README.md b/README.md index 4ed66df..fa10ed1 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ This is an autogenerated JavaScript SDK for OpenFGA. It provides a wrapper aroun - [Assertions](#assertions) - [Read Assertions](#read-assertions) - [Write Assertions](#write-assertions) + - [Retries](#retries) - [API Endpoints](#api-endpoints) - [Models](#models) - [Contributing](#contributing) @@ -619,6 +620,26 @@ const response = await fgaClient.writeAssertions([{ ``` +### Retries + +By default API requests are retried up to 15 times on 429 and 5xx errors and credential requests are retried to 3 times on 429 and 5xx errors. In both instances they will wait a minimum of 100 milliseconds between requests and up to a maximum of + +In order to change the behavior for API requests, pass a `retryParams` object in the `OpenFgaClient` constructor with a `maxRetry` property to control the amount of retries and a `minWaitInMs` to control the minimum wait time between retried requests. + +```javascript +const { OpenFgaClient } = require('@openfga/sdk'); // OR import { OpenFgaClient } from '@openfga/sdk'; + +const fgaClient = new OpenFgaClient({ + apiUrl: process.env.FGA_API_URL, // required + storeId: process.env.FGA_STORE_ID, // not needed when calling `CreateStore` or `ListStores` + authorizationModelId: process.env.FGA_AUTHORIZATION_MODEL_ID, // Optional, can be overridden per request + retryParams: { + maxRetry: 3, // retry up to 3 times on API requests + minWaitInMs: 250 // wait a minimum of 250 milliseconds between requests + } +}); +``` + ### API Endpoints | Method | HTTP request | Description |