Skip to content

index.TypeAlias.RuleResult

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

Type Alias: RuleResult

type RuleResult = boolean | string | Error;

Defined in: packages/graphql-casl/src/rules.ts:56

What a Check may return.

Remarks

true allows the field. false denies it with the default Forbidden error, a string denies it with that message, and an Error is thrown as-is — so a check can supply its own GraphQLError with extensions and a code.

A Check's context is any, so a value outside this union can still reach here — ctx.auth?.root is any, and undefined at runtime. Any such value is read for its truthiness, which makes undefined and null deny with the default Forbidden rather than crash. Return a boolean to stay on contract; the coercion is a safety net, not a second supported form.

API Reference

Clone this wiki locally