Pure (no side effects beyond the user-supplied loader functions) evaluation of compiled rules against a request.
Inputs
rules— list ofAbsinthePermission.Rule.t/0loads— list ofAbsinthePermission.Load.t/0to resolve before rules runschema— schema module; used to look up loader functionsargs— map of GraphQL argumentscontext— Absinthe context map; expected to contain:current_userand:permissions
Output
A AbsinthePermission.Decision.t/0 describing the verdict and why.
Semantics
- Rules whose condition does not fire are skipped silently.
- Rules whose condition fires AND whose permission is held by the caller are recorded as matched.
- Rules whose condition fires AND whose permission is NOT held
cause an immediate
:denydecision, witherror_message/permission/matched_rulespopulated. - Multiple rules combine with AND semantics — ALL fired rules must pass.
Summary
Functions
Evaluate a condition against the request state.
Evaluate an expression to a runtime value.
Evaluate post-op rules against an already-resolved value.
Evaluate pre-op rules. Resolves loads first, then runs each rule
in order. Returns {:ok, decision} on the happy path or
{:error, decision} when a load fails.
Check whether user_perms satisfies the rule's permission spec.
Resolve all loads by calling their registered loader. Returns
{:ok, %{name => record_or_nil}} or {:error, reason}.
Types
Functions
@spec condition_fires?(AbsinthePermission.Condition.t(), map(), ctx(), map()) :: boolean()
Evaluate a condition against the request state.
Evaluate an expression to a runtime value.
@spec evaluate_post([AbsinthePermission.Rule.t()], any(), args(), ctx(), atom() | nil) :: {:allow | :nullify | :deny, AbsinthePermission.Decision.t()}
Evaluate post-op rules against an already-resolved value.
For redaction (on_deny: :null), returns {:nullify, decision} if
the rule denies. For :error, returns {:deny, decision}.
Otherwise returns {:allow, decision} and the value passes through
unchanged.
@spec evaluate_pre( [AbsinthePermission.Rule.t()], [AbsinthePermission.Load.t()], module(), args(), ctx(), atom() | nil ) :: AbsinthePermission.Decision.t()
Evaluate pre-op rules. Resolves loads first, then runs each rule
in order. Returns {:ok, decision} on the happy path or
{:error, decision} when a load fails.
@spec has_permission?(AbsinthePermission.Rule.permission(), [String.t()]) :: boolean()
Check whether user_perms satisfies the rule's permission spec.
@spec resolve_loads([AbsinthePermission.Load.t()], module(), map(), ctx()) :: {:ok, %{required(atom()) => any()}} | {:error, String.t()}
Resolve all loads by calling their registered loader. Returns
{:ok, %{name => record_or_nil}} or {:error, reason}.