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

update.rb « organizations « customer_relations « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c6ae62193f96ba1f643e250f3866bda124a74157 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# frozen_string_literal: true

module Mutations
  module CustomerRelations
    module Organizations
      class Update < Mutations::BaseMutation
        include ResolvesIds

        graphql_name 'CustomerRelationsOrganizationUpdate'

        authorize :admin_organization

        field :organization,
              Types::CustomerRelations::OrganizationType,
              null: false,
              description: 'Organization after the mutation.'

        argument :id, ::Types::GlobalIDType[::CustomerRelations::Organization],
                required: true,
                description: 'Global ID of the organization.'

        argument :name,
                GraphQL::Types::String,
                required: false,
                description: 'Name of the organization.'

        argument :default_rate,
                GraphQL::Types::Float,
                required: false,
                description: 'Standard billing rate for the organization.'

        argument :description,
                GraphQL::Types::String,
                required: false,
                description: 'Description or notes for the organization.'

        def resolve(args)
          organization = ::Gitlab::Graphql::Lazy.force(GitlabSchema.object_from_id(args.delete(:id), expected_type: ::CustomerRelations::Organization))
          raise_resource_not_available_error! unless organization

          group = organization.group
          raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature disabled' unless Feature.enabled?(:customer_relations, group, default_enabled: :yaml)

          authorize!(group)

          result = ::CustomerRelations::Organizations::UpdateService.new(group: group, current_user: current_user, params: args).execute(organization)
          { organization: result.payload, errors: result.errors }
        end
      end
    end
  end
end