Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Question: How to deal with complex SQL query #1626
In my app, I have some "complex" queries and I don't really know how to integrate them with API Platform.
For now, I will talk about
Using an extension
Because API Platform automatically applies some join thanks to
Using a custom DataProvider
Actually, It does the job, but it seems not really natural to me. for the collection, I'm loosing many advantage like the pagination & all.
What is the best way to achieve that?
I saw we can disable the eager-loading. This looks the best idea IMHO, but before doing that, I wanted to be sure what I'm loosing. BTW, we don't you disable this feature by default ? because it could lead to many troubles isn't ?
Just use the extensions you want!
I'm doing this a lot:
If you're doing a native / manual query you don't need EagerLoadingExtension (nor FilterEagerLoadingExtension) because you would probably join manually all your relations.
We don't disable it by default because it has a huge performance impact when relations are serialized.
Ok thanks for you quick and nice answer.
I was thinking the same (about using custom data provider + extension provided by API Platform). But I thought it was too "hacky" to do that, and not so natural. However I don't know why ;)
Just one last question before closing this issue: There are no way to disable for few endpoint the EagerLoadingExtension / FilterEagerLoadingExtension), isn't ?
There is, just disable eager loading at the operation level see here.
Not hacky, those are meant to be used if you need too :).