Mutation for creating compliance requirement controls
What does this MR do and why?
Adds a mutation for creating controls for compliance requirements.
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
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.
How to set up and validate locally
- You must have a group with GitLab Ultimate license for testing this.
- Make sure the group has at least one compliance framework associated with it. If not then you can follow steps mentioned here for creating one.
- Now open the graphql explorer, for example http://gdk.test:3000/-/graphql-explorer, and run the following mutation
mutation createComplianceRequirement {
  createComplianceRequirement(
    input: {
      complianceFrameworkId: "gid://gitlab/ComplianceManagement::Framework/<framework_id>",
      params: {
        name: "Custom req 1",
        description: "some description"
      }
    }) {
    errors
    requirement {
      id
      name
      description
    }
  }
}- You should not get any error while running this and response would be something like:
{
  "data": {
    "createComplianceRequirement": {
      "errors": [],
      "requirement": {
        "id": "gid://gitlab/ComplianceManagement::ComplianceFramework::ComplianceRequirement/3",
        "name": "Custom req 1",
        "description": "some description"
      }
    }
  }
}- Note the ComplianceRequirement id you got in response.
- Now, lets create a control for this requirement by running following mutation:
mutation createComplianceRequirementControl {
  createComplianceRequirementsControl(
    input: {
      complianceRequirementId: "gid://gitlab/ComplianceManagement::ComplianceFramework::ComplianceRequirement/<id>",
      params: {
        name: "minimum_approvals_required_2",
        expression: "{\"operator\":\"=\",\"field\":\"minimum_approvals_required\",\"value\":2}"
      }
    }) {
    errors
    requirementsControl {
      id
      name
      expression
    }
  }
}- The above mutation should respond back with the requirementsControl object.
- You can also list down the requirementControl for a requirement belonging to a framework of a certain namespace by
query namespace {
  namespace(fullPath: "twitter") {
    id
    complianceFrameworks {
      nodes {
        id
        complianceRequirements { 
          nodes {
            id
            name
            complianceRequirementsControls {
              nodes {
                id
                name
                expression
              }
            }
          }
        }
      }
    }
  }
}Related to #512381 (closed)
Edited  by Hitesh Raghuvanshi