ash

Ash

Specific best practices and architectural patterns when working with Ash.

Details

Language / Topic
elixirElixir
Category
framework

Rules

balanced
- Define resources declaratively using `Ash.Resource` DSL — attributes, relationships, actions, and validations in one module.
- Use `Ash.Query` for composable, chainable queries; avoid direct Ecto queries when Ash provides the abstraction.
- Define resources with `Ash.Resource` DSL: `attributes`, `relationships`, `actions`, `validations`, and `policies` in a single module.
- Use `Ash.Query` for composable data access; chain filters, sorts, and loads declaratively.
- Implement custom actions for complex business logic — prefer `action` blocks over standalone functions.
- Use `Ash.Policy.Authorizer` to define authorization rules declaratively alongside the resource.
- Register all resources in an `Ash.Domain` module to enable cross-resource querying and relationship loading.