Skip to content

API reference > @kontsedal/olas-mutation-queue > MutationQueueOptions

MutationQueueOptions type ​

Options for mutationQueuePlugin(...). SPEC §13.3.

  • storage — the underlying durable store. localStorageAdapter() from @kontsedal/olas-persist is the typical default; indexedDbAdapter() when payloads are large or async write is preferred. - keyPrefix — namespace prefix in storage. Required to keep multiple apps on the same origin from colliding. Recommended shape: '<my-app>/mutations/v1'. - maxAttempts — bound on replay attempts per entry. After exhaustion the entry is dropped from storage and onReplayError fires with the final error. Defaults to 5. - onReplayError — called when the queue gives up on an entry: a failure after maxAttempts, a failure isRetryable rejects, a TTL expiry, or an entry whose mutation id no imported module registered. The handler is the integration point for telemetry / user-facing error toasts on lost mutations. - onWarn — soft conditions: malformed entry in storage, serialization failure (variables JSON cannot encode, such as a BigInt or a cycle). Default: console.warn.

Signature:

typescript
type MutationQueueOptions = {
  storage: StorageAdapter;
  keyPrefix: string;
  maxAttempts?: number;
  isRetryable?: (err: unknown, entry: QueueEntry) => boolean;
  onReplayError?: (err: unknown, entry: QueueEntry) => void;
  onReplayAttempt?: (err: unknown, entry: QueueEntry) => void;
  dedupeBy?: (mutationId: string, variables: unknown) => string | undefined;
  migrate?: (raw: unknown, fromVersion: number) => QueueEntry | null;
  ttlMs?: number;
  backoffMs?: number;
  maxBackoffMs?: number;
  maxEntryBytes?: number;
  onReplaySettle?: (entry: QueueEntry, result: unknown, queries: QueryHost) => void;
  onWarn?: (message: string, cause?: unknown) => void;
};

References: StorageAdapter, QueueEntry, QueryHost

Released under the MIT License.