Add mutation to create approval rules for a branch rule
What does this MR do and why?
Closes Create approvalProjectRuleCreate mutation (#441288 - closed)
Add mutation to create approval rules for a branch rule
Requires:
- branch_rule_id which is a GlobalID
- name
- approvals_required
- user_ids
- group_ids
Returns:
- approval_rule which is an instance of ApprovalProjectRule
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
In the graphql explorer:
Replace branchRuleId with an ID for your GDK using the following
query {
project(fullPath: "Flightjs/flight") {
branchRules {
nodes {
id
name
}
}
}
}
If you can't find one with the previous snippet you can generate your own by following this format
gid://gitlab/Projects::AllBranchesRule/#{project_id}
You may also want to replace the user and group ids. User 1 should be the root user which is admin so I believe they would have access to the project already but you may want to invite them.
Group 1 may also need to be invited to the project or alternatively create a new group and invite them to the project. Invite members to that group and they should be added to the approval rule.
mutation {
branchRuleApprovalProjectRuleCreate(input:{ branchRuleId: "gid://gitlab/Projects::AllBranchesRule/7", name: "New Rule", approvalsRequired: 1, userIds: [1], groupIds: [1]}) {
approvalRule {
id
name
type
approvalsRequired
eligibleApprovers {
nodes {
id
username
email
}
}
}
}
}