blob: 71a46a04a1ce568439ccea20b907b51261aff9a1 (
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
|
# frozen_string_literal: true
module Mutations
module Achievements
class Award < BaseMutation
graphql_name 'AchievementsAward'
include Gitlab::Graphql::Authorize::AuthorizeResource
field :user_achievement,
::Types::Achievements::UserAchievementType,
null: true,
description: 'Achievement award.'
argument :achievement_id, ::Types::GlobalIDType[::Achievements::Achievement],
required: true,
description: 'Global ID of the achievement being awarded.'
argument :user_id, ::Types::GlobalIDType[::User],
required: true,
description: 'Global ID of the user being awarded the achievement.'
authorize :award_achievement
def resolve(args)
achievement = authorized_find!(id: args[:achievement_id])
recipient_id = args[:user_id].model_id
result = ::Achievements::AwardService.new(current_user, achievement.id, recipient_id).execute
{ user_achievement: result.payload, errors: result.errors }
end
end
end
end
|