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
|
# frozen_string_literal: true
module Mutations
module Achievements
class Create < BaseMutation
graphql_name 'AchievementsCreate'
include Gitlab::Graphql::Authorize::AuthorizeResource
field :achievement,
::Types::Achievements::AchievementType,
null: true,
description: 'Achievement created.'
argument :namespace_id, ::Types::GlobalIDType[::Namespace],
required: true,
description: 'Namespace for the achievement.'
argument :name, GraphQL::Types::String,
required: true,
description: 'Name for the achievement.'
argument :avatar, ApolloUploadServer::Upload,
required: false,
description: 'Avatar for the achievement.'
argument :description, GraphQL::Types::String,
required: false,
description: 'Description of or notes for the achievement.'
authorize :admin_achievement
def resolve(args)
namespace = authorized_find!(id: args[:namespace_id])
raise Gitlab::Graphql::Errors::ResourceNotAvailable, '`achievements` feature flag is disabled.' \
if Feature.disabled?(:achievements, namespace)
result = ::Achievements::CreateService.new(namespace: namespace,
current_user: current_user,
params: args).execute
{ achievement: result.payload, errors: result.errors }
end
def find_object(id:)
GitlabSchema.object_from_id(id, expected_type: ::Namespace)
end
end
end
end
|