When denormalizing, IriConverter::getItemFromIri may get called, and therefore calls the ItemDataProvider. When doing this, we loose the context.
I saw this while trying to use force_eager = false on an Operation. When calling this Operation, the first call to ItemDataProvider has the correct operation_name. But then, when the call comes from getItemFromIri, the operation_name is null. Therefore, force_eager is not fetched from the initial Operation attributes.
Cause: https://github.com/api-platform/core/blob/master/src/Serializer/AbstractItemNormalizer.php#L362
@dunglas may I ask why you're removing those context properties when serializing a relation?
Because some configurations rely on operation_name we should propagate those to the (de)normalization of relations no?
For example:
Product:
itemOperations:
put:
method: 'PUT'
attributes: ['force_eager' => false]
Assuming Product->Relation->Foo, when Relation will get denormalize'd the force_eager flag will be true because we lost the operation_name information.
I don't remember exactly :( But if you remove this line, I bet some tests will fail and you'll get an explanation.
This seems to be fixed by PR #1264
Most helpful comment
I don't remember exactly :( But if you remove this line, I bet some tests will fail and you'll get an explanation.