Skip to content

index.Interface.ValidateGraphQLRulesOptions

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

Interface: ValidateGraphQLRulesOptions

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

Options for validateGraphQLRules.

Properties

conditionFields?

readonly optional conditionFields?: "schema" | "none";

Defined in: packages/graphql-casl/src/validateGraphQLRules.ts:47

Whether a condition's field names are checked against the subject type.

Remarks

'schema' (the default) requires every path in conditions to name a field of the subject — and, for a dotted path, a field of each type along the way. 'none' checks only the shape of the conditions (the operators, $and/$or/$nor groups) and lets any field name through.

Use 'none' when subjects are database models rather than GraphQL types — codegen mappers, say — and a rule legitimately conditions on a column the schema does not expose. Subject and fields names are always checked; those are schema names.


operators?

readonly optional operators?: "leaf" | "matcher";

Defined in: packages/graphql-casl/src/validateGraphQLRules.ts:67

Which condition operators a rule may use.

Remarks

'matcher' (the default) accepts every operator CASL's matcher knows, which is all a rule needs to be checked — can(), createCan.

'leaf' accepts only the operators a leaf filter adapter is handed, so it also reports $not, $mod and $options. Use it when the rules are folded into a query filter by accessibleBy or scopeArgs with a leaf adapter: the walker throws on those three, per request, rather than drop a condition and widen access. A skeleton adapter passes conditions through untranslated and needs no more than 'matcher'.

The conditions under an $elemMatch are not held to the shorter list: the walker hands them to the adapter's leaf as written, so whether they translate is up to the adapter.

API Reference

Clone this wiki locally