Sha256: 92c6f48d9bcce85a41b36efaab477e4a529184a40ee419db595c67622eb6a837

Contents?: true

Size: 1.13 KB

Versions: 54

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

54 entries across 54 versions & 2 rubygems

Version Path
decidim-comments-0.9.3 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.9.2 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.9.1 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.9.0 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.8.4 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.8.3 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.8.2 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.8.1 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.8.0 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.7.4 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.7.3 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.7.2 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.7.1 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.7.0 app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.6.8 app/types/decidim/comments/commentable_mutation_type.rb
decidim-0.6.8 decidim-comments/app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.6.7 app/types/decidim/comments/commentable_mutation_type.rb
decidim-0.6.7 decidim-comments/app/types/decidim/comments/commentable_mutation_type.rb
decidim-comments-0.6.6 app/types/decidim/comments/commentable_mutation_type.rb
decidim-0.6.6 decidim-comments/app/types/decidim/comments/commentable_mutation_type.rb