Sha256: bacd0b1438405639532171280377e5d901f3100a8a4b58e94136620a778ee86f
Contents?: true
Size: 1.13 KB
Versions: 10
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Decidim module Comments CommentableMutationType = GraphQL::ObjectType.define do name "CommentableMutation" description "A commentable which includes its available mutations" field :id, !types.ID, "The Commentable's unique ID" field :addComment, Decidim::Comments::CommentType do description "Add a new comment to a commentable" argument :body, !types.String, "The comments's body" argument :alignment, types.Int, "The comment's alignment. Can be 0 (neutral), 1 (in favor) or -1 (against)'", default_value: 0 argument :userGroupId, types.ID, "The comment's user group id. Replaces the author." resolve lambda { |obj, args, ctx| params = { "comment" => { "body" => args[:body], "alignment" => args[:alignment], "user_group_id" => args[:userGroupId] } } form = Decidim::Comments::CommentForm.from_params(params) Decidim::Comments::CreateComment.call(form, ctx[:current_user], obj) do on(:ok) do |comment| return comment end end } end end end end
Version data entries
10 entries across 10 versions & 2 rubygems