Welcome to mirror list, hosted at ThFree Co, Russian Federation.

resolves_subscription.rb « mutations « concerns « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ed9fb5fceb0ce7fbf2993b680a12fdc18ce6ea4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

module Mutations
  module ResolvesSubscription
    extend ActiveSupport::Concern

    included do
      argument :subscribed_state,
               GraphQL::BOOLEAN_TYPE,
               required: true,
               description: 'The desired state of the subscription.'
    end

    def resolve(project_path:, iid:, subscribed_state:)
      resource = authorized_find!(project_path: project_path, iid: iid)
      project = resource.project

      resource.set_subscription(current_user, subscribed_state, project)

      {
        resource.class.name.underscore.to_sym => resource,
        errors: errors_on_object(resource)
      }
    end
  end
end