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