ash-project / ash-project/ash

Standardize type for returning extra notifications from hook functions and manual actions

Open
#1,877 0 comments 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

Right now if you want to add extra notifications in hooks or actions you return an additional last tuple element with notifications. But there is clear inconsistency in terms of format for that element:

For example, `after_action_fun` says that it should be simple list of `[Ash.Notifier.Notification.t()]`, while `before_action_fun` expects a map with `%{notifications: list(Ash.Notifier.Notification.t())}`.

I think it would be helpful to introduce a type for `[notification] | %{notifications: [notifications]}` and then use it in public interfaces allowing a user to return either variant.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the public interfaces for `after_action_fun` and `before_action_fun`, including how their final tuple elements are typed and consumed. Define the shared return type and apply it consistently to the hook and manual-action interfaces so both notification formats are accepted, then verify the relevant type checks and interface tests pass.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.