Plugging in your own subject-area logic
How project logic gets into the standard flows without changing generated code: hooks, their order, and how they behave on errors and with nested objects.
Topics in this subject area
- 1.Hooks: types and timing
Which hook points exist (before and after the database change, per operation) and how a hook is registered.
- 2.Field hooks
Reusable logic for a single value: store it encrypted, derive it, normalise it. What a field hook looks like, how you assign it to a field and when it runs.
- 3.The order within a write operation
Recursion, before hooks, validation, saving, after hooks. Why a before hook may still fill a required field.
- 4.Hooks for nested objects and cascades
Hooks also fire for children and for objects deleted by a cascade. How they are collected, in which order they run, and when no hooks fire.
- 5.A hook writes itself
When a hook creates something through a system layer itself, that is a write inside a write. Each gets its own level: its own checks, its own hooks, one shared commit. The depth is bounded and measurable.
- 6.When a hook fails
An error in a hook rolls back the whole request. How the error reaches the client.