Replies: 7 comments
-
Did you set up serialization groups? You could also disable eager loading for this resource. |
Beta Was this translation helpful? Give feedback.
-
Already try disabling the eager loading, even with EXTRA_LAZY it's still doing the fetch :) |
Beta Was this translation helpful? Give feedback.
-
As an aside, naming the entity in plural is really confusing! 🙈 |
Beta Was this translation helpful? Give feedback.
-
Please see doctrine/orm#4389 (comment) and doctrine/orm#4389 (comment) It's how Doctrine works. |
Beta Was this translation helpful? Give feedback.
-
So indeed, what we could do in API Platform is to always eager load such an association, even if it's not in the serializer group. Counter intuitive, I know! Doing an unnecessary join ends up saving us one query. |
Beta Was this translation helpful? Give feedback.
-
The alternative is to enable partial loading, but that comes with its own problems... (Hence not enabled by default.) |
Beta Was this translation helpful? Give feedback.
-
Hi @teohhanhui! Thanks for the feedback, indeed those plural entities need to be changed ;) |
Beta Was this translation helpful? Give feedback.
-
After taking a look at the SQL queries, I've just figured out Api platform was requesting useless queries from object not displayed in the JSON.
How to reproduce:
In the DB:
Then:
In the doctrine debug, you'll see:
The query on mum_locations seems to be useless, it shouldn't be hydrated by getOneOrNullResult
Am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions