Closed Be-P closed 10 months ago
// api/src/services/items.ts:680
for (const key of keys) {
const { revisions, nestedActionEvents: nestedActionEventsO2M } = await payloadService.processO2M(
**payload**, // This should became something like **payloadAfterHooks**
key,
opts
);
childrenRevisions.push(...revisions);
nestedActionEvents.push(...nestedActionEventsO2M);
}
@br41nslug do you want me to create a PR?
I've triaged the issue so you definitely try your hand at fixing it 😄 want me to assign you @Be-P ?
which branch should I point to with the fixing PR? let me first try to create a PR as exercise, I don't want to slow down your lifecycle if I mess up with something eheh
@Be-P which api is causing this issue? i tried with PATCH /items/:collection
, its working fine for me, i was able to update data in filter hook
@br41nslug i have added a fix for it. lmk your thoughts.
Describe the Bug
I want to modify on a filter() hook the payload that's being used to update nested entities. For example, imagine a School has a one2Many with Students. From the School detail I can modify the student e.g. name, and I'll receive in the filter() hook a payload like this:
{ id: 1, students: {create:[], delete: [], update: [{id:1, name:"foo bar"}]}
Now, in the hook I would like to modify it as follows:{ id: 1, students: {create:[], delete: [], update: [{id:1, name:"foo",surname:"bar"}]}
and return it. I've tried to do so, but the modification does not have effect: in the Student filter() hook I still get the original, not modified value.To Reproduce
Create an o2m relation, modify the payload, and see it doesn't actually update the nested relation entity
Directus Version
10.8.2
Hosting Strategy
Self-Hosted (Docker Image)