Repository navigation
Replies: 7 comments
|
Did you set up serialization groups? You could also disable eager loading for this resource. |
|
Already try disabling the eager loading, even with EXTRA_LAZY it's still doing the fetch :) |
|
As an aside, naming the entity in plural is really confusing! 🙈 |
|
Please see doctrine/orm#4389 (comment) and doctrine/orm#4389 (comment) It's how Doctrine works. |
|
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. |
|
The alternative is to enable partial loading, but that comes with its own problems... (Hence not enabled by default.) |
|
Hi @teohhanhui! Thanks for the feedback, indeed those plural entities need to be changed ;) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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:
{ "@context":"\/api\/contexts\/Mums", "@id":"\/api\/mums", "@type":"hydra:Collection", "hydra:member":[ { "@id":"\/api\/mums\/0test0", "@type":"Mums", "mumId":"0test0" } ], "hydra:totalItems":1 }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?
All reactions