Is there documentation somewhere for the order in which hooks execute? Specifically between fields and collection hooks.
Example: I have a field called
which uses a
field hook to format from the title (this is copied from the payload remix example). On that same collection I have a
collection hook that generates a uriPath using that
Currently I think I'm hitting a race condition in the order those fire. I need the
to be formatted (the field hook) before generating the
. I know I could move the
field hook to the collection level but I'd rather understand what is happening.
Here is the source code for the update operation:https://github.com/payloadcms/payload/blob/master/src/collections/operations/update.ts#L158-L187
are you returning the slugified value from your field hook? You should be able to access that via
in your collection beforeValidate function
If I'm reading all the correctly, Field hooks finish in no particular order but Collection hooks should wait for all the Field hooks to finish before running.
I'll need to figure out how to reproduce the issue I was seeing. Naturally it's not happening all the time (hence the wondering about a race condition)
That is correct, field validations run in parallel
@dianoga you might find this discussion relevanthttps://github.com/payloadcms/payload/discussions/2785
(and an upcoming PRhttps://github.com/payloadcms/payload/discussions/2889#discussioncomment-6730791