Skip to content

index.Function.not

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

Function: not()

function not(operand, error?): CheckableRule;

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

Inverts a rule: passes when the operand denies, denies when it passes.

Parameters

operand

Rule

The rule to invert.

error?

string | Error

The denial message or error to use when operand passes.

Returns

CheckableRule

A checkable rule.

Remarks

The operand's error is discarded — it explains why the operand failed, which is the reason this rule passed. Supply error to say why the inverted rule denied; without one it denies with Forbidden.

Example

Mutation: { deleteAccount: not(isImpersonating, 'Not while impersonating') }

API Reference

Clone this wiki locally