diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-28 21:11:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-28 21:11:01 +0300 |
commit | 7c5f1bfac791045e54386b9c9bb56ee24afc68ca (patch) | |
tree | a11c8dff3994899c25acacb383c0a70522a24cd1 /app/graphql/mutations/work_items/subscribe.rb | |
parent | d62fd6e04c272d48dccde4033529ca97c27502f6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql/mutations/work_items/subscribe.rb')
-rw-r--r-- | app/graphql/mutations/work_items/subscribe.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/graphql/mutations/work_items/subscribe.rb b/app/graphql/mutations/work_items/subscribe.rb new file mode 100644 index 00000000000..a29c3416c3d --- /dev/null +++ b/app/graphql/mutations/work_items/subscribe.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module Mutations + module WorkItems + class Subscribe < BaseMutation + graphql_name 'WorkItemSubscribe' + + argument :id, ::Types::GlobalIDType[::WorkItem], + required: true, + description: 'Global ID of the work item.' + + argument :subscribed, + GraphQL::Types::Boolean, + required: true, + description: 'Desired state of the subscription.' + + field :work_item, Types::WorkItemType, + null: true, + description: 'Work item after mutation.' + + authorize :update_subscription + + def resolve(args) + work_item = authorized_find!(id: args[:id]) + + update_subscription(work_item, args[:subscribed]) + + { + work_item: work_item, + errors: [] + } + end + + private + + def update_subscription(work_item, subscribed_state) + work_item.set_subscription(current_user, subscribed_state, work_item.project) + end + end + end +end |