debian-mirror-gitlab/app/graphql/mutations/customer_relations/organizations/create.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.6 KiB
Ruby
Raw Normal View History

2021-11-11 11:23:49 +05:30
# frozen_string_literal: true
module Mutations
module CustomerRelations
module Organizations
class Create < BaseMutation
2022-04-04 11:22:00 +05:30
graphql_name 'CustomerRelationsOrganizationCreate'
2021-11-11 11:23:49 +05:30
include ResolvesIds
include Gitlab::Graphql::Authorize::AuthorizeResource
field :organization,
Types::CustomerRelations::OrganizationType,
null: true,
description: 'Organization after the mutation.'
argument :group_id, ::Types::GlobalIDType[::Group],
required: true,
description: 'Group for the organization.'
argument :name,
GraphQL::Types::String,
required: true,
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,
2021-11-18 22:05:49 +05:30
description: 'Description of or notes for the organization.'
2021-11-11 11:23:49 +05:30
2021-12-11 22:18:48 +05:30
authorize :admin_crm_organization
2021-11-11 11:23:49 +05:30
def resolve(args)
group = authorized_find!(id: args[:group_id])
result = ::CustomerRelations::Organizations::CreateService.new(group: group, current_user: current_user, params: args).execute
{ organization: result.payload, errors: result.errors }
end
def find_object(id:)
GitlabSchema.object_from_id(id, expected_type: ::Group)
end
end
end
end
end