Sha256: c6a62c1c68e1d763c12d25286f36711f944b38d738d07ef8e6b23dd9004248f3

Contents?: true

Size: 1.34 KB

Versions: 34

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, "Whether the object can have new comments or not" do
        property :accepts_new_comments?
      end

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

      field :commentsHaveVotes, !types.Boolean, "Whether 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

34 entries across 34 versions & 2 rubygems

Version Path
decidim-comments-0.8.4 app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.8.3 app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.8.2 app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.8.1 app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.8.0 app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.7.4 app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.7.3 app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.7.2 app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.7.1 app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.7.0 app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.6.8 app/types/decidim/comments/commentable_interface.rb
decidim-0.6.8 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.6.7 app/types/decidim/comments/commentable_interface.rb
decidim-0.6.7 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.6.6 app/types/decidim/comments/commentable_interface.rb
decidim-0.6.6 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.6.5 app/types/decidim/comments/commentable_interface.rb
decidim-0.6.5 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.6.4 app/types/decidim/comments/commentable_interface.rb
decidim-0.6.4 decidim-comments/app/types/decidim/comments/commentable_interface.rb