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

feat: add mutation type to validator and trigger execute functions #119

Merged
merged 1 commit into from
Mar 24, 2021

Conversation

wschurman
Copy link
Member

Why

It's sometimes helpful to have information about what type of mutation is being executed when running validators/triggers, and in the case of update mutations what the previous value was. This is similar to the functionality expressible in rails with ActiveModel::Dirty.

Some examples:

  • Only allow valid field state transitions on update mutations (finite state machine)
  • Run only some logic on update in a validator

How

Add mutation info object to trigger and validator execution functions

Test Plan

Run tests.

@wschurman wschurman requested review from ide and quinlanj March 23, 2021 21:33
@codecov
Copy link

codecov bot commented Mar 23, 2021

Codecov Report

Merging #119 (cb09af6) into master (b11dbc0) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #119      +/-   ##
==========================================
+ Coverage   95.08%   95.10%   +0.01%     
==========================================
  Files          67       67              
  Lines        1689     1694       +5     
  Branches      202      203       +1     
==========================================
+ Hits         1606     1611       +5     
  Misses         81       81              
  Partials        2        2              
Flag Coverage Δ
integration 95.10% <100.00%> (+0.01%) ⬆️
unittest 95.10% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...s/entity/src/EntityMutationTriggerConfiguration.ts 100.00% <ø> (ø)
packages/entity/src/EntityMutatorFactory.ts 100.00% <ø> (ø)
packages/entity/src/EntityMutator.ts 98.20% <100.00%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b11dbc0...cb09af6. Read the comment docs.

@wschurman wschurman merged commit ef40fa5 into master Mar 24, 2021
@wschurman wschurman deleted the @wschurman/mutation-type branch March 24, 2021 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants