api-platform / api-platform/core
GraphQL RDBMS Performance
- 主要語言
- PHP
- 星號
- 2.6k
- 分支
- 980
- 平均合併
- 2 天 2 小時
- 30 天內合併 PR
- 51
描述
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.
貢獻指南
評估
這個 Issue 還沒有評估資料。