Hook execution order

default discord avatar
dianoga10 months ago
4

Is there documentation somewhere for the order in which hooks execute? Specifically between fields and collection hooks.



Example: I have a field called

slug

which uses a

beforeValidate

field hook to format from the title (this is copied from the payload remix example). On that same collection I have a

beforeValidate

collection hook that generates a uriPath using that

slug

field.



Currently I think I'm hitting a race condition in the order those fire. I need the

slug

to be formatted (the field hook) before generating the

uriPath

. I know I could move the

formatSlug

field hook to the collection level but I'd rather understand what is happening.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.