Skip to content

index.TypeAlias.UnconditionedSubjectMode

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

Type Alias: UnconditionedSubjectMode

type UnconditionedSubjectMode = typeof UnconditionedSubjectMode[keyof typeof UnconditionedSubjectMode];

Defined in: packages/graphql-casl/src/createCan.ts:39

What createCan does when a bare-subject check is made against a subject whose only matching rules carry conditions.

Remarks

ability.can('update', 'Note') asks CASL "is updating a Note possible at all?", not "may I update this Note?" — a rule of can('update', 'Note', { userId }) makes the bare check return true for every caller. Omitting getSubjectData there silently discards the conditions, with no type error to catch it.

  • 'warn' (default) — allow the check, but log once per rule. Non-breaking.
  • 'throw' — deny with an explanatory error. Recommended for new projects.
  • 'allow' — say nothing. For deliberate "is this possible at all" gates, e.g. guarding a list field whose rows are filtered inside the resolver.

The object names each mode: onUnconditionedSubject: UnconditionedSubjectMode.Throw.

API Reference

Clone this wiki locally