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

update.rb « achievements « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8bb95ac41f35d2435da31756280cab7fa5426657 (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
35
36
37
38
39
40
41
42
# frozen_string_literal: true

module Mutations
  module Achievements
    class Update < BaseMutation
      graphql_name 'AchievementsUpdate'

      include Gitlab::Graphql::Authorize::AuthorizeResource

      field :achievement,
        ::Types::Achievements::AchievementType,
        null: true,
        description: 'Achievement.'

      argument :achievement_id, ::Types::GlobalIDType[::Achievements::Achievement],
        required: true,
        description: 'Global ID of the achievement being updated.'

      argument :name, GraphQL::Types::String,
        required: false,
        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)
        achievement = authorized_find!(id: args[:achievement_id])

        args.delete(:achievement_id)
        result = ::Achievements::UpdateService.new(current_user, achievement, args).execute
        { achievement: result.payload, errors: result.errors }
      end
    end
  end
end