Class: Mutations::AwardEmojis::Add

Inherits:
Base
  • Object
show all
Defined in:
app/graphql/mutations/award_emojis/add.rb

Constant Summary

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Instance Method Summary collapse

Methods inherited from BaseMutation

#api_user?, #current_user, #errors_on_object, #ready?

Instance Method Details

#resolve(args) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/graphql/mutations/award_emojis/add.rb', line 8

def resolve(args)
  awardable = authorized_find!(id: args[:awardable_id])

  check_object_is_awardable!(awardable)

  service = ::AwardEmojis::AddService.new(awardable, args[:name], current_user).execute

  {
    award_emoji: (service[:award] if service[:status] == :success),
    errors: service[:errors] || []
  }
end