Skip to content
github-actions[bot] edited this page Oct 14, 2026 · 11 revisions

index

graphql-casl — generic CASL permissions middleware for GraphQL resolvers.

Remarks

Everything here is schema-agnostic: pass your own generated Resolvers / ResolversTypes to the type helpers and you get a fully-derived subject union without any manual type listing. The runtime helpers (createCan, createTyped, subjectsOf, accept, deny) are bound to your app's context shape and ability builder at call time.

Abilities are statically typed: derive a GraphQLAbility from your SubjectMap and build it with createGraphQLAbility (or rehydrate stored rules with buildGraphQLAbility). Conditions use CASL's standard mongo-query operators ($eq/$in/$gt/…); subjects are detected via __typename.

Modules:

  • schemaTypes — type helpers derived from generated Resolvers/ResolversTypes
  • rules — the graphql-middleware rule layer (Rule, PermissionsMap, accept, deny)
  • applyPermissions — validates a map against the schema and applies it
  • validateArgs — argument validation as a rule, via any Standard Schema validator
  • validateGraphQLRules — validates stored ability rules against the schema
  • ability — CASL Action / Actions / AbilityLike
  • graphqlAbility — the schema-typed GraphQLAbility / createGraphQLAbility / buildGraphQLAbility
  • subjects — subjectsOf / createTyped (and deprecated createSubjects)
  • createCan — the factory tying abilities to rules
  • grants — granted scopes: grants / granted, a parent's decision reused by its fields

Namespaces

Classes

Interfaces

Type Aliases

Variables

Functions

API Reference

Clone this wiki locally