Skip to content
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

Validation on Fields from Hooks #1191

Open
thekevinbrown opened this issue Sep 23, 2024 · 0 comments
Open

Validation on Fields from Hooks #1191

thekevinbrown opened this issue Sep 23, 2024 · 0 comments

Comments

@thekevinbrown
Copy link
Member

Describe the bug
If a hook sets a value that doesn't exist on the entity, the code succeeds in execution, but the result is not what the developer expects.

From Slack: The code in BeforeCreateHook for SustainabilityAttribute was supposed to set { organization: { id: 'org_##########' } } but in my haste, I accidentally told it to set { organization_id: 'org_##########' } } (the field is named organization_id in the db). In order to debug it, I have to set breakpoints in your code to see what's happening since the error returned isn't really helpful. It would be nice if it gave us something like invalid field: organization_id on entity SustainabilityAttribute .

Expected behavior
In development, we should validate that the fields set by hooks are real fields. In production we should not do this check unless explicitly enabled as it will have performance implications.

Actual behavior
Code runs without error, result is not what developer expected.

Additional context
https://graphweaver.slack.com/archives/D0730MYM74Z/p1726103546839589?thread_ts=1723672001.215299&cid=D0730MYM74Z

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

No branches or pull requests

1 participant