ash-project / ash-project/ash

Allow to read applying another non-read policy

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

Description

**Problem**

Sometimes, we want to read data applying another non-read policy, e.g. to read posts updatable by an actor.

For now, we have to create a special read action (e.g. `:read_updatable`) and copy the policy of the corresponding action (e.g. of the `:update` here).

**Solution**

This could be solved by adding a `policy` option to the reads function (`Api.read`, `Api.exists?`, `Api.sum`, etc.) to apply a specific policy.

And using it like:

```elixir
MyResource
|> Api.read!(actor: actor, policy: :update)
```

**Alternative**

Won't do, to complicate to propagate a different non-read policy and suggest the workaround above.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the read functions named in the issue—Api.read, Api.exists?, and Api.sum—and how they currently select policies. Compare the proposed policy: :update flow with the existing special-read workaround. Done means the relevant read APIs accept and apply a selected non-read policy without requiring a copied read action.

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
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.