Sha256: d483df308d569bf17f40b58d110484924b8b529331e88db7c73e1d89160caace
Contents?: true
Size: 691 Bytes
Versions: 148
Compression:
Stored size: 691 Bytes
Contents
# frozen_string_literal: true module Decidim module Comments # A GraphQL resolver to handle `upVote` and `downVote` mutations # It creates a vote for a comment by the current user. class VoteCommentResolver def initialize(options = { weight: 1 }) @weight = options[:weight] end 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 end end end
Version data entries
148 entries across 148 versions & 2 rubygems