api-platform / api-platform/core
GraphQL RDBMS Performance
- Lenguaje dominante
- PHP
- Estrellas
- 2.6k
- Forks
- 980
- Merge medio
- 2 d 2 h
- PR fusionados (30 d)
- 51
Descripción
With GraphQL you can create custom API request, but it seems that on backend all available data are loaded from DB in the same way as for REST API.
I have eager with fetch_partial enabled.
I have Category with one-to-one relation to CategoryDetail. If I want to to ask only for all CategoryDetail IDs, I will create query like this:
```
{
categories {
categoryDetail {
id
}
}
}
```
But from DB all columns are loaded, so query looks like this:
```
SELECT
c0_.id AS id_0,
c0_.idMaxId AS idMaxId_1,
c0_.isSeparator AS isSeparator_2,
c0_.isHidden AS isHidden_3,
c0_.isLocked AS isLocked_4,
c0_.lft AS lft_5,
c0_.lvl AS lvl_6,
c0_.rgt AS rgt_7,
c0_.name AS name_8,
c0_.created AS created_9,
c0_.changed AS changed_10,
c1_.id AS id_11,
c1_.descriptionTop AS descriptionTop_12,
c1_.descriptionBottom AS descriptionBottom_13,
c0_.idWebsite AS idWebsite_18,
c0_.idParent AS idParent_19,
c0_.idUrlItem AS idUrlItem_20,
c1_.idWebsite AS idWebsite_21,
c1_.idCategory AS idCategory_22
FROM
Category c0_
LEFT JOIN
CategoryDetail c1_ ON c0_.id = c1_.idCategory
WHERE
c0_.idWebsite = ?
ORDER BY c0_.id ASC
```
But this query would be sufficient
```
SELECT
c0_.id AS id_0,
c1_.id AS id_11,
c0_.idWebsite AS idWebsite_18,
c1_.idCategory AS idCategory_22
FROM
Category c0_
LEFT JOIN
CategoryDetail c1_ ON c0_.id = c1_.idCategory
WHERE
c0_.idWebsite = ?
ORDER BY c0_.id ASC
```
Is it possible to optimalize DB queries for GraphQL like this? Or do you plan similar feature in future?
Thanks.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.