Update mutation for compliance requirement controls

What does this MR do and why?

Adding a mutation for updating a compliance requirement control for a compliance framework.

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

Numbered steps to set up and validate the change are strongly suggested.

  1. You must have a group with GitLab Ultimate license for testing this.
  2. 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.
  3. 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
    }
  }
}
  1. 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"
      }
    }
  }
}
  1. Note the ComplianceRequirement id you got in response.
  2. 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
    }
  }
}
  1. The above mutation should respond back with the requirementsControl object, note the control id.
  2. Now update the control object by running following mutation in graphql explorer, the response should not contain any errors:
mutation updateComplianceRequirementsControl {
  updateComplianceRequirementsControl(
    input: {
      id: "gid://gitlab/ComplianceManagement::ComplianceFramework::ComplianceRequirementsControl/<id>",
      params: {
        name: "project_visibility_not_internal",
        expression: "{\"operator\":\"=\",\"field\":\"project_visibility\",\"value\":\"private\"}"
      }
    }
  ){
    errors
    requirementsControl {
      id
      name
      expression
    }
  }
}

Related to #512381 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports

Loading