Skip to content

Allow to update requirement status widget through GraphQL

charlie ablett requested to merge 365991-cablett-graphql-update-requirement into master

What does this MR do and why?

Allows for an update to the status of a Work Item of type Requirement.

Behind the scenes, it creates a new Test Report with the given status.

Passed and Satisfied are functionally equivalent, but only passed is accepted as a parameter.

How to set up and validate locally

  1. Create a requirement (you can do this via the UI - you can use https://gdk.test:3443/group/project/-/requirements_management/requirements)
  2. Get its work item ID:
query {
  project(fullPath: "group/project") {
    workItems(types: [REQUIREMENT]) {
      nodes {
        id
        title
        widgets{
          type
          ... on WorkItemWidgetStatus {
            status
          }
        }
      }
    }
  }
}

You'll get something like:

{
  "data": {
    "project": {
      "workItems": {
        "nodes": [
          {
            "id": "gid://gitlab/WorkItem/464",
            "title": "be awesome",
            "widgets": [
              {
                "type": "STATUS",
                "status": "failed"
              },
              {
                "type": "DESCRIPTION"
              }
            ]
          }
        ]
}}}}
  1. Plug that gid (in this case "gid://gitlab/Issue/464") into the mutation below:
mutation updateWorkItem {
  workItemUpdate(input: {id: "gid://gitlab/Issue/464", statusWidget: {status: "passed"}}) {
    workItem {
      widgets {
        ... on WorkItemWidgetStatus {
          status
        }
      }
    }
    errors
  }
}
  1. You'll get the following response for passed (it comes back as satisfied)
{
  "data": {
    "workItemUpdate": {
      "workItem": {
        "widgets": [
          {
            "status": "satisfied"
          },
          {}
        ]
      },
      "errors": []
    }
  }
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #365991 (closed)

Edited by charlie ablett

Merge request reports

Loading