I am working with Symfony 3 (with Doctrine and FosRestBundle) and I've been trying to find a way to, by default, not retrieve entity relationships when querying an entity. Instead I'm aiming to opt into joins for finer control over what data is returned based on context.
For example, say I have a Post entity with One-To-Many relationships to Comments and Tags, I want to by default, when querying the Post entity, not return the nested comments or tags. My current repository query looks as simple as;
$query = $this->createQueryBuilder('p');
return $query->getQuery()->getResult();
This however returns the nested entities. What I need is the ability to opt into the linked entities by manually adding a join statement. Is this possible? Thanks!