Improve GraphQL for approvals on environment details page
Background
At the moment it's not possible to fully implement deployment approvals on the new Environment details page using only GraphQL api. We have the following issues related to it:
1. Unified approval rules are not returned by GraphQL API
If a user sets up a unified approval rule, no information about that can be found in GraphQL api. In this case we cannot provide approvals functionality for the page at all.
approval_summary
for a single deployment
2. Limit of only returning Current GraphQL implementation only returns approval_summary for a single deployment. If we query multiple deployments, all the deployments following the first one, are not returned, which renders the environment details page useless.
related file : /ee/app/graphql/ee/types/deployment_type.rb
userPermissions.approveDeployment
for a single deployment
3. Limit of returning Same as above, this data is only returned for a single deployment, and the page cannot be rendered properly
Proposal
backend would need to additionally expose required_approval_count
field in Protected Environment Type. This would be feasible. So if required_approval_count > 0
or approval_rules is not empty
, then we should show approval button for all rows.
Points 2 and 3 are as designed and frontend will work around these limitations. For more context see this comment from Shinya.