-
-
Notifications
You must be signed in to change notification settings - Fork 930
Closed
Labels
Description
API Platform version(s) affected: 3.1.8
Description
I'm trying to update an embedded relation with a PATCH operation. Basically this use case but with a PATCH instead of a PUT. However my relation is deleted and recreated instead of updated.
How to reproduce
- Create a resource with a collection.
- Try to update an item of this collection with a PATCH operation.
Possible Solution
I tried to debug the issue. I think the issue happens because when the request reach this line, $data['@id']
contains the id of my relation but $context[self::OBJECT_TO_POPULATE]
is set and contains the entire collection instead of just the item.
If I update this line with
$childContext = $this->createChildContext($context, $attribute, $format);
$childContext[self::OBJECT_TO_POPULATE] = null;
$values[$index] = $this->denormalizeRelation($attribute, $propertyMetadata, $className, $obj, $format, $childContext);
then the request behave as expected, but I'm really not sure that this is the right fix.
Please tell me if I can do anything to help fix the issue (or if I'm doing anything wrong).
benjamin-alxr, mdieudonne, forabelo and broncha