Class: Decidim::Comments::VoteCommentResolver
- Inherits:
-
Object
- Object
- Decidim::Comments::VoteCommentResolver
- Defined in:
- decidim-comments/app/resolvers/decidim/comments/vote_comment_resolver.rb
Overview
A GraphQL resolver to handle ‘upVote` and `downVote` mutations It creates a vote for a comment by the current user.
Instance Method Summary collapse
- #call(obj, _args, ctx) ⇒ Object
-
#initialize(options = { weight: 1 }) ⇒ VoteCommentResolver
constructor
A new instance of VoteCommentResolver.
Constructor Details
#initialize(options = { weight: 1 }) ⇒ VoteCommentResolver
Returns a new instance of VoteCommentResolver.
8 9 10 |
# File 'decidim-comments/app/resolvers/decidim/comments/vote_comment_resolver.rb', line 8 def initialize( = { weight: 1 }) @weight = [:weight] end |
Instance Method Details
#call(obj, _args, ctx) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'decidim-comments/app/resolvers/decidim/comments/vote_comment_resolver.rb', line 12 def call(obj, _args, ctx) Decidim::Comments::VoteComment.call(obj, ctx[:current_user], weight: @weight) do on(:ok) do |comment| return comment end on(:invalid) do return GraphQL::ExecutionError.new(I18n.t("votes.create.error", scope: "decidim.comments")) end end end |