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

revoke.rb « achievements « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9d21b1c374101e83c833dbab345bcba6d031f429 (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
# frozen_string_literal: true

module Mutations
  module Achievements
    class Revoke < BaseMutation
      graphql_name 'AchievementsRevoke'

      include Gitlab::Graphql::Authorize::AuthorizeResource

      field :user_achievement,
        ::Types::Achievements::UserAchievementType,
        null: true,
        description: 'Achievement award.'

      argument :user_achievement_id, ::Types::GlobalIDType[::Achievements::UserAchievement],
        required: true,
        description: 'Global ID of the user achievement being revoked.'

      authorize :award_achievement

      def resolve(args)
        user_achievement = authorized_find!(id: args[:user_achievement_id])

        result = ::Achievements::RevokeService.new(current_user, user_achievement).execute
        { user_achievement: result.payload, errors: result.errors }
      end

      def find_object(id:)
        GitlabSchema.object_from_id(id, expected_type: ::Achievements::UserAchievement)
      end
    end
  end
end