Sha256: b4971c6e88b8d3fc1c2d136a29308e14236d5f4ba6172c76a95ed700f10fc222

Contents?: true

Size: 1.7 KB

Versions: 25

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    ProposalType = GraphQL::ObjectType.define do
      name "Proposal"
      description "A proposal"

      interfaces [
        -> { Decidim::Comments::CommentableInterface },
        -> { Decidim::Core::AuthorableInterface },
        -> { Decidim::Core::CategorizableInterface },
        -> { Decidim::Core::ScopableInterface },
        -> { Decidim::Core::AttachableInterface }
      ]

      field :id, !types.ID
      field :title, !types.String, "This proposal's title"
      field :body, types.String, "This proposal's body"
      field :state, types.String, "The state in which proposal is in"
      field :address, types.String, "The physical address (location) of this proposal"
      field :reference, types.String, "This proposa'ls unique reference"

      field :publishedAt, Decidim::Core::DateTimeType do
        description "The date and time this proposal was published"
        property :published_at
      end

      field :endorsements, !types[Decidim::Core::AuthorInterface], "The endorsements of this proposal." do
        resolve ->(proposal, _, _) {
          proposal.endorsements.map(&:normalized_author)
        }
      end

      field :endorsementsCount, types.Int do
        description "The total amount of endorsements the proposal has received"
        property :proposal_endorsements_count
      end

      field :voteCount, types.Int do
        description "The total amount of votes the proposal has received"
        resolve ->(proposal, _args, _ctx) {
          current_component = proposal.component
          proposal.proposal_votes_count unless current_component.current_settings.votes_hidden?
        }
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-proposals-0.20.1 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.20.0 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.19.1 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.18.1 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.19.0 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.17.2 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.18.0 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.17.1 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.16.1 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.17.0 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.16.0 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.15.2 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.15.1 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.15.0 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.14.4 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.14.3 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.14.2 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.14.1 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.13.1 app/types/decidim/proposals/proposal_type.rb
decidim-proposals-0.12.2 app/types/decidim/proposals/proposal_type.rb