fix(serializer): resilient denormalizeRelation capability#7474
fix(serializer): resilient denormalizeRelation capability#7474soyuka merged 1 commit intoapi-platform:4.1from
Conversation
|
Thanks for tagging @soyuka 👏 |
|
Should it target 4.2 instead ? |
|
Denormalizing for a resource's relation still isn't a valid case where you'd expect an IRI to be When the intention is to denormalize (assuming: write a newly persisted object), you should be able to expect the item is there, and throw an exception if the item isn't there. An IRI not being there (yet) means that persistence / flush didn't finish yet, and the IRI is a read concern that should to be generated post-flush (during post-write normalization). By allowing Regarding the related discussion #5136 about filtering subresources, when a relation (e.g. OneToMany) is filtered the collection of results shouldn't contain or be In the end the expectation imho would be: when you request the IriConverter for an IRI, you always should be able to expect to get one, or handle the exceptions otherwise. |
|
I agree about IRI generation but there are some cases where you know an item will exist but for now doesn't. I think it may be a valid use case where you'd like to just ignore that IRI generation. Still, I don't want to break that interface and the IriConverter::getResourceFromIri return type is |
71fa539 to
989f24c
Compare
989f24c to
b5dee8a
Compare
Co-authored-by: Nicolas LAURENT <aegypius@users.noreply.github.com> Co-authored-by: Javier Sampedro <jsampedro77@gmail.com> fix(laravel): serializer attributes on Eloquent methods (#7416) fixes #7289 fixes #7338 fix(validator): custom message was not translated (#7424) fixes #7336 fix(serializer): resilient denormalizeRelation capability (#7474) fix(doctrine): properly set properties according to interface (#7487) fix(graphql): stateOptions to get filter class (#7485)
We may want the
denormalizeRelationnot to throw anItemNotFoundExceptionbut there's no way of knowing that we're denormalizing. This adds a context flag so that users can returnnullinstead of throwing. Ping @rvanlaak another use case where you'd likenullfrom the IriConverter (relates to #7401).