Sha256: e43c5c58561a26c3cd89afd7bbee4437707f1ed0778ec7f483c420a649687531

Contents?: true

Size: 1.34 KB

Versions: 14

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

14 entries across 14 versions & 2 rubygems

Version Path
decidim-comments-0.4.3 app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.4.2 app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.4.1 app/types/decidim/comments/commentable_interface.rb
decidim-0.4.3 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-0.4.2 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-0.4.1 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.4.0 app/types/decidim/comments/commentable_interface.rb
decidim-0.4.0 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.3.2 app/types/decidim/comments/commentable_interface.rb
decidim-0.3.2 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.3.1 app/types/decidim/comments/commentable_interface.rb
decidim-0.3.1 decidim-comments/app/types/decidim/comments/commentable_interface.rb
decidim-comments-0.3.0 app/types/decidim/comments/commentable_interface.rb
decidim-0.3.0 decidim-comments/app/types/decidim/comments/commentable_interface.rb