I have an Entity coming from a Doctrine repository, that I want to serialize and then return back. The Entity has of course several relations, those relations have also some realtions, and so on. Every relation that is needed, is already populated, BUT NOT ALL.
The properties of the Entities already have some serialization groups.
public function getListAction(SerializerInterface $serializer) { // ... Getting data from database with Doctrine $entities = $this->someRepository->findByConditions(/* ... */); $serializer->serialize($entities, 'json'); } In the profiler I see that it starts to fill up the rest of the relations. Starts to execute database queries to fill up all the missing properties. Then eventually the query times out.
Question: Is there a way to tell the serializer, to only serialize the given object, but do not fill up the missing relations? In other words, disable lazy loading?
Adding a new serialization group would be also not good, because some Entity has a reference to itself $parent. So it'll again end up in executing queries.