related entities not loaded?
See original GitHub issueMy entity has a Many2One relationship
/**
* @var Industry
*
* @ORM\ManyToOne(targetEntity="Industry", fetch="EAGER")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="IndustryId", referencedColumnName="Id")
* })
*/
private $industry;
But when requesting from this resource, the related entities are not fetched.
The results would only include:
"industry": "/api/industries/1",
Instead of the whole entity.
I’m using the default configuration
eager_loading:
# To enable or disable eager loading.
enabled: true
# Fetch only partial data according to serialization groups.
# If enabled, Doctrine ORM entities will not work as expected if any of the other fields are used.
fetch_partial: false
# Max number of joined relations before EagerLoading throws a RuntimeException.
max_joins: 30
# Force join on every relation.
# If disabled, it will only join relations having the EAGER fetch mode.
force_eager: true
which makes the fetch="EAGER" annotation redundant, yet I added it to see if it made any difference.
I could only got to get the related entities by creating a serialization group and adding each of the properties on the related entity to that group. While it works, it seems a bit convoluted, and from what I gathered from documentation and configuration the relationships were going to be forced to be eager by API-Platform.
Am I missing something here?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Entity Framework not loading related objects - Stack Overflow
My problem is, it seems to get a list of records back, but related items are not loaded. My 'Transformer.UnpackTask' method takes the...
Read more >Loading Related Entities - EF6 - Microsoft Learn
Eager loading is the process whereby a query for one type of entity also loads related entities as part of the query. Eager...
Read more >Entity Framework Core 5 – Pitfalls To Avoid and Ideas to Try
Queries not including related data. EF Core moved away from lazy loading as a default feature. Navigation properties still exist as part of ......
Read more >Explicit Loading Related Entities in EF 6 and EF Core
Here you will learn how to load related entities in an entity graph explicitly. Explicit loading is valid in EF 6 and EF...
Read more >Blog App – Reading Related Data using .NET EF Core
In this case, firstly, a principal entity is loaded, but related data is not loaded at that time. Then a navigation property can...
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

@ismail1432 I believe they are looking for something similar to #284 I answered the OP’s question involving serializer groups on SO, if that provides some more context.
They were expecting api-platform to automatically embed all related entity association properties, with the
force_eager=trueoption, assuming it to meanforce_embed=true.Yeah, I had completely misread the docs. 😨
Off I go to create many serialization groups to cover all the required possibilities.