Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor common mutation logic #123

Open
XanderVertegaal opened this issue Sep 18, 2024 · 1 comment
Open

Refactor common mutation logic #123

XanderVertegaal opened this issue Sep 18, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@XanderVertegaal
Copy link
Contributor

A lot of validation logic is now duplicated across our mutations, and it is easy to forget to add contributors. LettercraftMutation should take over some of the former and prevent us as developers from doing the latter.

@XanderVertegaal XanderVertegaal added the enhancement New feature or request label Sep 18, 2024
@XanderVertegaal XanderVertegaal added this to the Start logging milestone Sep 18, 2024
@XanderVertegaal XanderVertegaal self-assigned this Sep 18, 2024
@XanderVertegaal
Copy link
Contributor Author

XanderVertegaal commented Sep 18, 2024

The current plan is:

LettercraftMutation should get new methods:

  • add_contributors: raises NotImplemented if subsclassing mutations don't overwrite this function.
  • validate_input: pass if not overwritten, validates the mutation input object.
  • perform_mutation: contains all current logic of mutate_object.

The existing method mutate_object should, in sequence:

  1. start an atomic transaction
  2. call validate_input()
  3. call perform_mutation()
  4. call add_contributors()
  5. validate the resulting mutated objects (with full_clean())
  6. catch any errors
  7. return the resulting/modified objects

Still unclear is how to get the manual updates (now done using excluded_fields) in this flow.

@lukavdplas lukavdplas moved this to On hold in Lettercraft Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: On hold
Development

No branches or pull requests

1 participant