Sha256: 306c04a8068cb1f6401d85647e7d74f2d509f106fcfd1f030bbdd6ded065260f

Contents?: true

Size: 1.34 KB

Versions: 10

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true
module Decidim
  module Comments
    # This interface represents a commentable object.
    CommentableInterface = GraphQL::InterfaceType.define do
      name "CommentableInterface"
      description "A commentable interface"

      field :id, !types.ID, "The commentable's ID"

      field :type, !types.String, "The commentable's class name. i.e. `Decidim::ParticipatoryProcess`" do
        property :commentable_type
      end

      field :acceptsNewComments, !types.Boolean, "Wether the object can have new comments or not" do
        property :accepts_new_comments?
      end

      field :commentsHaveAlignment, !types.Boolean, "Wether the object comments have alignment or not" do
        property :comments_have_alignment?
      end

      field :commentsHaveVotes, !types.Boolean, "Wether the object comments have votes or not" do
        property :comments_have_votes?
      end

      field :comments do
        type !types[CommentType]

        argument :orderBy, types.String, "Order the comments"

        resolve lambda { |obj, args, _ctx|
          SortedComments.for(obj, order_by: args[:orderBy])
        }
      end

      field :hasComments, !types.Boolean, "Check if the commentable has comments" do
        resolve lambda { |obj, _args, _ctx|
          obj.comments.size.positive?
        }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
decidim-comments-0.1.0 app/types/decidim/comments/commentable_interface.rb
decidim-0.1.0 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.0.8.1 app/types/decidim/comments/commentable_interface.rb
decidim-0.0.8.1 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.0.7 app/types/decidim/comments/commentable_interface.rb
decidim-0.0.7 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.0.6 app/types/decidim/comments/commentable_interface.rb
decidim-0.0.6 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.0.5 app/types/decidim/comments/commentable_interface.rb
decidim-0.0.5 decidim-comments/app/types/decidim/comments/commentable_interface.rb