Update GraphQL API to support environment detail page
Problem
Originally raised in !91573 (diffs, comment 1021201259).
It looks like deployment_approval_data
is serialized for each deployment row in the environment detail page, thus find_approval_rule_for
is executed for each row, which hits group.users.exists?(user.id)
. This could result in N+1 issue as tested.
We should reconsider the way how we serialize the data in environment detail page.
Proposal
- In deployments index page, Frontend checks if the environment is protected, and if so, the details of the protection (e.g. who can deploy/approve). We can use this query for this purpose.
- If the environment is protected and requires an approval, frontend renders the approval button in all rows. When a user clicks the button, frontend renders the approval details. We can use this query for this purpose.
- By this reason, we don't need to check
find_approval_rule_for
for every deployment rows. We can drop the legacy path. - The frontend will need to be rewritten in Vue in order to use this endpoint: #23036 (closed)
A few notes:
- Batch-loading approval details with GraphQL BatchLoader would result in a very complicated process that could be another complexity and fragility point. We should avoid such process by fetching the necessary information efficiently, as described above.
Related
Edited by Shinya Maeda