Skip to content

index.TypeAlias.AbilityLike

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

Type Alias: AbilityLike

type AbilityLike = {
  can: boolean;
};

Defined in: packages/graphql-casl/src/ability.ts:55

Minimal structural type for anything with a CASL-style can method — what the rule layer needs to check an action against a subject.

Remarks

A typed GraphQLAbility satisfies it; the method shape keeps type-checking for consumers who annotate their ability with this type, unlike a (...args: any[]) shim.

The optional third argument is CASL's field-level check (can('read', user, 'email')), which createCan(...).fields uses to decide a whole type's fields from the ability alone.

Methods

can()

can(
   action, 
   subject, 
   field?): boolean;

Defined in: packages/graphql-casl/src/ability.ts:57

Parameters

action

Action

subject

any

field?

string

Returns

boolean

API Reference

Clone this wiki locally