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
|
# frozen_string_literal: true
module Mutations
module Organizations
class Create < BaseMutation
graphql_name 'OrganizationCreate'
authorize :create_organization
field :organization,
::Types::Organizations::OrganizationType,
null: true,
description: 'Organization created.'
argument :name, GraphQL::Types::String,
required: true,
description: 'Name for the organization.'
argument :path, GraphQL::Types::String,
required: true,
description: 'Path for the organization.'
argument :description, GraphQL::Types::String,
required: false,
description: 'Description of the organization.'
def resolve(args)
authorize!(:global)
result = ::Organizations::CreateService.new(
current_user: current_user,
params: create_params(args)
).execute
{ organization: result.payload, errors: result.errors }
end
private
def create_params(params)
return params unless params.key?(:description)
params[:organization_detail_attributes] = { description: params.delete(:description) }
params
end
end
end
end
|