Hi,
I have a somewhat unexpected error when trying to manage a has_one
relationship that is defined between a Session
(source) and a Summary
(target) - each Session has at most one summary.
session |> Ash.Changeset.manage_relationship(:summary, %{}, on_missing: :destroy)
** (KeyError) key :phase not found in: #FiveWhys.Understand.Session<
...
>
I tried various other combinations of parameters (e.g., type: delete
, providing an explicit %{id: summary_id}
in the input
argument, etc., and every time I get this cryptic key :phase not found
. I assume it’s some internal parameter because :phase
is not present in any of my attributes.
I read and re-read the help page for manage_relationship/4
many times, and I feel like it’s the proper way to delete a has_one
relationship, but of course I might be using it incorrectly. In which case any suggestion on how to destroy the summary would be appreciated.
Note: I can of course go the long route, e.g.,
session = session |> Ash.load!(:summary)
session.summary |> Ash.Changeset.for_destroy(:destroy) |> Ash.destroy!()
and it works, but I would ideally like to define an :update
action on Session to destroy the summary, to make it available via GraphQL etc.
I would appreciate any advice on how to do it best.
Victor