Skip to content

index.TypeAlias.Rule

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

Type Alias: Rule

type Rule = (resolve, parent, args, context, info) => Promise<any>;

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

The callable middleware form used in PermissionsMap entries.

Parameters

resolve

ResolveFn

parent

unknown

args

unknown

context

any

info

GraphQLResolveInfo

Returns

Promise<any>

Remarks

A rule receives the wrapped resolve function plus the standard resolver arguments. It either calls resolve(...) to allow the field, or throws to deny it. createCan produces rules that enforce CASL abilities; accept and deny are the always-pass / always-fail primitives.

The declared return type is a promise, and a denial is always delivered as a rejection. An allowed field, though, may hand back whatever resolve returned — a plain value when the resolver is synchronous — exactly as a GraphQL resolver may. Callers await the result, which handles both.

API Reference

Clone this wiki locally