Modify `manage_relationship` to handle destroy first, or add an option to prioritize it
- 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.**
When trying to delete the existing item and add a new one with `manage_relationship`, failures can be occur due to identity issues. This happens because `delete_unused` is after ‘handle_input’ in `manage_relationship`.
Steps to Reproduce
https://gist.github.com/nallwhy/d0ec48edcfff5a4d34bf5124ef010b63
1. Click [Add author] button
2. Click [Remove author] of the first author.
3. Input "author1" to name of the remain author.
4. Click [Save]
**Describe the solution you'd like**
It would be beneficial to have the option to perform `delete_unused` before `handle_input`.
**Describe alternatives you've considered**
I have no alternatives idea.
**Express the feature either with a change to resource syntax, or with a change to the resource interface**
For example
```elixir
changes do
change manage_relationship(:authors, type: :direct_control, delete_unused_first?: true)
end
```
**Additional context**
x
Contributor guide
Research direction
Start by locating `manage_relationship` and tracing how `delete_unused` and `handle_input` are ordered. Reproduce the identity issue using the linked gist and the listed author-edit steps, then inspect the resource `changes` syntax. Done means the requested ordering can be selected or applied without the delete-and-replace failure, with behavior covered by a regression test.
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
- 35/100