Skip to content

cyclic dependencies between collection - hooks produce endless loop #211

Answered by jmikrut
zaunermax asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @zaunermax — we really appreciate your interest in Payload. Great to hear that you're enjoying working with it. Got a lot more goodness on the way too.

What I'd do in this case, is first check if the metaCategory or category already has the relationship that it needs, before actually updating it in your hooks.

That way, if the proper relationship already exists, you won't update again needlessly, and then the hooks won't re-run. Just need to introduce some type of loop-breaking logic. That's what I'd do.

This is totally a common thing. Need to break the cycle in one way or another.

Does that help?

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zaunermax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants