ash-project / ash-project/ash

Proposal (4.0): Inline global preparations into actions at compile time

Open
#1,830 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Elixir
Stars
2.5k
Forks
426
Avg merge
23h 26m
Merged PRs (30d)
46

Description

**Is your feature request related to a problem? Please describe.**

We ran into an issue where we were loading data in a preparation for a default read action, which caused other issues, but we weren't getting the new warning advising not to do that (introduced in e5656b6cc2b191dd26d6ab96b5563fbe1fcaa5fe).

The reason is because the preparation was a global one, ie. in a `preparations` block, not in a specific action. These preparations aren't inlined into the action at compile time, meaning calling `Ash.Resource.Info.action(MyResource, :read)` won't list the preparation even though it will apply.

**Describe the solution you'd like**

These preparations should be added to each of the actions they apply to, at compile time. For now this will be all actions, as preparations can't have conditions, but later on conditions may be added.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how global preparations are represented and how actions are compiled, then compare that with what Ash.Resource.Info.action(MyResource, :read) exposes. Done means preparations from a preparations block appear on every applicable action at compile time, while preserving the stated future possibility of conditional preparations.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.