Normalization group not working in nested embedded entities
See original GitHub issueI have the following entity structure: BrandMessage
has Campaign
has (CampaignSettings
and RunningTime
). So when I call the /api/brand-messages
api the entities CampaignSettings
and RunningTime
are nested in the third level. Also, CampaignSettings
and RunningTime
are embedded entities.
When I call the /api/campaigns
api, everything works as expected. runningTime
and settings
are present:
{
"@context": "/app_dev.php/api/contexts/Campaign",
"@id": "/app_dev.php/api/campaigns",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/app_dev.php/api/campaigns/e64a026e-1b88-11e7-8825-0242ac110002",
"@type": "Campaign",
"app": "/app_dev.php/api/apps/e64d3274-11e7-1b88-8825-0242ac110002",
"runningTime": {
"daysLeftTillEnd": 99,
"daysLeftTillStart": -74,
"end": "2017-07-16T02:31:13+00:00",
"isFinished": false,
"start": "2017-01-23T08:02:29+00:00"
},
"settings": {
"participationLimit": 1,
"receiptMandatory": true,
"requiredProductCount": 5,
"rewardInEuroCent": 100
},
"title": "...",
"description": "..."
},
...
}
But when I call the /api/brand-messages
api, these properties (runningTime
and settings
) are just null
:
{
"@context": "/app_dev.php/api/contexts/BrandMessage",
"@id": "/app_dev.php/api/brand-messages",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/app_dev.php/api/brand-messages/e64d3274-1b88-11e7-8825-0242ac110002",
"@type": "BrandMessage",
"backgroundImage": null,
"campaign": {
"@id": "/app_dev.php/api/campaigns/e64a3837-1b88-11e7-8825-0242ac110002",
"@type": "Campaign",
"app": "/app_dev.php/api/apps/e64d3274-11e7-1b88-8825-0242ac110002",
"runningTime": null,
"settings": null,
"title": "...",
"description": "..."
},
"colorPair": "secondary",
"httpCallToActionLabel": "",
"httpLink": "",
"important": true,
"type": "CAMPAIGN",
"title": "..."
},
...
],
...
}
I double checked all the serialisation groups and they even work in the third nesting level for title
and description
. Is there a default nesting limit for nested properties or something like that? Or am I facing a bug? 😃
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
API Platform : Groups with nested entities work only when ...
It work but only when i remove @ApiResource from the nested entity and i need it to expose my CRUD services.
Read more >Nested field type | Elasticsearch Guide [8.5] | Elastic
The nested type is a specialised version of the object data type that allows arrays of objects to be indexed in a way...
Read more >The Serialization Process - API Platform
Changing the Serialization Context on a Per-item Basis The example above demonstrates how you can modify the normalization/denormalization context based on the ...
Read more >Chapter 8. Structuring a Redux store - liveBook · Manning
This chapter covers. Structuring relational data in Redux; Learning the pros and cons of nested data versus normalized data; Using the normalizr package ......
Read more >Use nested and repeated fields | BigQuery - Google Cloud
For example, denormalizing an orders schema without using nested and repeated fields might require you to group the data by a field like...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@soyuka yes, while applying this framework (which I really love btw) in my project I stumbled across multiple problems and was not aware, that they might all have the same or similar root cause. It was totally confusing for me as well. Sorry, about that 😃
@nik-lampe you wrote lots of different issues / comments so it’s hard to track ^^. I added a comment in your pull request, but if there are 2 different problems we need to carefully test both and fix both separately!
null
issue (IMHO it’s a serialization group issue, not related to how theResourceClassResolver
works (or maybe but I’ve a lot of embedded relations and no such issue)Parent
entity is not aware of theChild
metadata. Therefore, it can not serialize properties it doesn’t know of. This is harder to fix, because the metadata is the one fromParent::class
though it should beParent::class + Child::class
. The good question there is “how do we find everychild
thatextends
theparent
?”. An easy fix is might be to patch this class by retrieving the metadata for table inheritance.