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