Archive Label GraphQL endpoint

What does this MR do and why?

Adds a GraphQL endpoint to update the archived attribute of labels.

This MR is a prerequisite for #554227 (closed). We need to add the API first, in order to be able to archive/unarchive the label from the frontend.

Labels in labels list

  1. When a label is not archived, add an action from the Labels list "Archive". This should be the last action in the ellipsis menu.
  2. When a label is archived, add an action from the Labels list "Unarchive". This should be the first action in the ellipsis menu.

🛠️ with ❤️ at Siemens

References

Issue: #4233

Screenshots

graphql

How to set up and validate locally

  1. Enable feature flag with rails c:
 Feature.enable(:labels_archive)
  1. Get the global label id from a label: Label.last.to_global_id
  2. Use curl or the GraphQL explorer to mutate the label. Change id and archived in the variables:
curl --request POST \
  --url https://gdk.test:3443/api/graphql \
  --header 'Authorization: Bearer <glpat>' \
  --header 'Content-Type: application/json' \
  --data '{
  "query": "mutation labelUpdate($id: LabelID!, $archived: Boolean) {\n  labelUpdate(input: { id: $id, archived: $archived }) {\n    label {\n      id\n      archived\n    }\n    errors\n  }\n}\n",
  "operationName": "labelUpdate",
  "variables": {
    "id": "gid://gitlab/ProjectLabel/78",
    "archived": true
  }
}'
mutation labelUpdate($id: LabelID!, $archived: Boolean) {
  labelUpdate(input: { id: $id, archived: $archived }) {
    label {
      id
      archived
    }
    errors
  }
}

{
  "id": "gid://gitlab/ProjectLabel/780",
  "archived": true
}

MR acceptance checklist

checklist

Related to #4233

Edited by Nicholas Wittstruck

Merge request reports

Loading