Skip to content

index.Function.race

github-actions[bot] edited this page Nov 30, 2026 · 26 revisions

Function: race()

function race(...rules): CheckableRule;

Defined in: packages/graphql-casl/src/combinators.ts:323

Sequential or: evaluates operands in order and stops at the first one that passes.

Parameters

rules

...Rule[]

The operands, in evaluation order.

Returns

CheckableRule

A checkable rule.

Remarks

When all of them fail, the last operand's error is thrown.

Put the cheap or common case first — a passing first operand means the rest never run.

Like or, an operand that throws counts as a failed operand and the next one still runs; the error is rethrown only if no operand passes.

Example

Query: { report: race(isCachedAsAllowed, askOpenFga) }

API Reference

Clone this wiki locally