2019-06-21 04:45:27 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module AwardEmojis
|
|
|
|
class Base < BaseMutation
|
2020-11-20 18:09:37 +00:00
|
|
|
include ::Mutations::FindsByGid
|
|
|
|
|
|
|
|
NOT_EMOJI_AWARDABLE = 'You cannot award emoji to this resource.'
|
|
|
|
|
2019-06-21 04:45:27 +00:00
|
|
|
authorize :award_emoji
|
|
|
|
|
|
|
|
argument :awardable_id,
|
2020-10-08 03:08:39 +00:00
|
|
|
::Types::GlobalIDType[::Awardable],
|
2019-06-21 04:45:27 +00:00
|
|
|
required: true,
|
2021-08-10 12:11:00 +00:00
|
|
|
description: 'Global ID of the awardable resource.'
|
2019-06-21 04:45:27 +00:00
|
|
|
|
|
|
|
argument :name,
|
2021-07-23 15:09:21 +00:00
|
|
|
GraphQL::Types::String,
|
2019-06-21 04:45:27 +00:00
|
|
|
required: true,
|
|
|
|
description: copy_field_description(Types::AwardEmojis::AwardEmojiType, :name)
|
|
|
|
|
|
|
|
field :award_emoji,
|
|
|
|
Types::AwardEmojis::AwardEmojiType,
|
|
|
|
null: true,
|
2021-08-10 12:11:00 +00:00
|
|
|
description: 'Award emoji after mutation.'
|
2019-06-21 04:45:27 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-11-20 18:09:37 +00:00
|
|
|
def authorize!(object)
|
|
|
|
super
|
|
|
|
raise_resource_not_available_error!(NOT_EMOJI_AWARDABLE) unless object.emoji_awardable?
|
2019-06-21 04:45:27 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|