8000 Fix afterOperation hooks in one-to-one relationships with foreign keys by lushkovsky-s · Pull Request #9525 · keystonejs/keystone · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix afterOperation hooks in one-to-one relationships with foreign keys #9525

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lushkovsky-s
Copy link
Contributor

Description

This PR fixes an issue where afterOperation hooks weren't properly triggered on both sides of one-to-one relationships with db: { foreignKey: true }. Previously, when updating a relationship from the side without the foreign key, only the hooks for that list were triggered, while the actual database change occurred on the list with the foreign key.

Related Issues

Issue #9433

@dcousens dcousens requested review from dcousens and emmatown March 3, 2025 21:56
Copy link
Member
@emmatown emmatown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this makes sense to do. While the behaviour of relationships only running hooks on the local list (with the exception of nested creates going through the normal create flow) can certainly be a bit confusing, I think it's clearer for the behaviour to be exactly that rather than adding more exceptions like running only afterOperation and only for one-to-one relationships. Also, the performance impact of fetching the related items to pass into the hooks when it will often be unnecessary doesn't seem worth it.

@stuible
Copy link
stuible commented Mar 25, 2025

The performance concerns are very valid but I, for one, would love some way to enable this behaviour for related lists. Opt-in? I just had this issue come up in my own codebase today.

@dcousens
Copy link
Member
dcousens commented Mar 25, 2025

@stuible I concur this 820F can be a foot-gun if you're not thinking about it from day zero.

Maybe we can write up an example/relationship-hooks, and that can show a usecase that is confusing; from there we can then dive into how that could be improved?

Pull requests accepted 💛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0