-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: separate out EntityMutationValidator #68
Conversation
Codecov Report
@@ Coverage Diff @@
## master #68 +/- ##
==========================================
+ Coverage 94.55% 94.57% +0.02%
==========================================
Files 59 59
Lines 1488 1494 +6
Branches 167 168 +1
==========================================
+ Hits 1407 1413 +6
Misses 79 79
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Executable" sounds like a program. Here is a proposal:
Make two named types: a trigger type and a validator type. Both might be aliases for the same underlying type.
If we never intend to treat triggers and validators the same, they don't need to share an interface. In fact it might be desirable for them not to share and interface so that we don't imply that triggers and validators are interchangeable. Put another way, TS interfaces don't let us declare intent, and the intents behind triggers and validators differ.
I also think it's worth considering just using a plain function for the type unless there is a need to add more methods to the trigger interface.
That's good reasoning for separating out the types. I updated the PR to reflect that. As for the class vs function, see this comment: #65 (comment). I'll definitely consider making it a function in the future if usage seems to not make use of the benefits of a class, but having it as a class has turned out to be reasonably helpful for privacy policy rules. |
Why
Now that these are used for both triggers and validators, they should have a distinct name. I considered the following, but am open to others suggestions as well:
EntityMutationCallback
- callbacks usually don't prevent something from running, so it didn't make sense for validationEntityMutationHandler
- handlers generally refer to overriding behavior of the framework rather than hooking into it.EntityMutationExecutable
- the method inside it is calledexecuteAsync
so this was the natural nameEntityMutationLambda
- not really a JS termEntityMutationHook
- The termhook
refers more to the when it is run rather than the what is run IMO.How
TS renames.
Test Plan
yarn tsc