Allow updating user subscriptions on a work item with GraphQL

Related to #389443 (closed)

What does this MR do and why?

In !113416 (merged) we added the Notifications widget to work items that returns the subscription state for the current user.

This MR extends the widget so it can be updated with the updateWorkItem mutation using the subscribed argument.

No UI changes, only API implementation.

How to set up and validate locally

  1. Create a new work item and make a note of its ID
project, root = Project.first, User.first

wi = WorkItem.create!(author: root, project: project, title: 'Test Work Item', work_item_type_id: 1)
wi.id
  1. Log in as root and visit http://gdk.test:3000/gitlab-org/gitlab-test/-/issues/{WORK_ITEM_ID}. The notifications toggle in the right sidebar should be on.
  2. Visit http://gdk.test:3000/-/graphql-explorer and run the following mutation:
mutation updateWorkItem {
  workItemUpdate(input: {id: "gid://gitlab/WorkItem/WORK_ITEM_ID", notificationsWidget: {subscribed: false}}) {
    workItem {
      id
      widgets{
        ... on WorkItemWidgetNotifications {
          subscribed
        }
      }
    }
  }
}
  1. Visit http://gdk.test:3000/gitlab-org/gitlab-test/-/issues/{WORK_ITEM_ID} and verify that the notifications toggle is off.
  2. Execute mutation one more time changing the argument to subscribed: true and verify again that the response and toggle match the expected value.

MR acceptance checklist

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

Edited by Eugenia Grieff

Merge request reports

Loading