Sha256: 4168c2e157580021f4f0c0f9780d5444c6c00bf8aba5fe7b39c1411a3065c0b6

Contents?: true

Size: 1.55 KB

Versions: 37

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    class ProposalListHelper < Decidim::Core::ComponentListBase
      # only querying published posts
      def query_scope
        super.published
      end
    end

    class ProposalFinderHelper < Decidim::Core::ComponentFinderBase
      # only querying published posts
      def query_scope
        super.published
      end
    end

    class ProposalsType < Decidim::Api::Types::BaseObject
      implements Decidim::Core::ComponentInterface

      graphql_name "Proposals"
      description "A proposals component of a participatory space."

      field :proposals, type: Decidim::Proposals::ProposalType.connection_type, description: "List all proposals", connection: true, null: true do
        argument :order, Decidim::Proposals::ProposalInputSort, "Provides several methods to order the results", required: false
        argument :filter, Decidim::Proposals::ProposalInputFilter, "Provides several methods to filter the results", required: false
      end

      field :proposal, type: Decidim::Proposals::ProposalType, description: "Finds one proposal", null: true do
        argument :id, GraphQL::Types::ID, "The ID of the proposal", required: true
      end

      def proposals(filter: {}, order: {})
        Decidim::Proposals::ProposalListHelper.new(model_class: Proposal).call(object, { filter: filter, order: order }, context)
      end

      def proposal(id:)
        Decidim::Proposals::ProposalFinderHelper.new(model_class: Proposal).call(object, { id: id }, context)
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
decidim-proposals-0.27.9 lib/decidim/api/proposals_type.rb
decidim-proposals-0.27.8 lib/decidim/api/proposals_type.rb
decidim-proposals-0.27.7 lib/decidim/api/proposals_type.rb
decidim-proposals-0.27.6 lib/decidim/api/proposals_type.rb
decidim-proposals-0.26.10 lib/decidim/api/proposals_type.rb
decidim-proposals-0.26.9 lib/decidim/api/proposals_type.rb
decidim-proposals-0.27.5 lib/decidim/api/proposals_type.rb
decidim-proposals-0.26.8 lib/decidim/api/proposals_type.rb
decidim-proposals-0.27.4 lib/decidim/api/proposals_type.rb
decidim-proposals-0.27.3 lib/decidim/api/proposals_type.rb
decidim-proposals-0.26.7 lib/decidim/api/proposals_type.rb
decidim-proposals-0.26.5 lib/decidim/api/proposals_type.rb
decidim-proposals-0.27.2 lib/decidim/api/proposals_type.rb
decidim-proposals-0.27.1 lib/decidim/api/proposals_type.rb
decidim-proposals-0.26.4 lib/decidim/api/proposals_type.rb
decidim-proposals-0.27.0 lib/decidim/api/proposals_type.rb
decidim-proposals-0.26.3 lib/decidim/api/proposals_type.rb
decidim-proposals-0.27.0.rc2 lib/decidim/api/proposals_type.rb
decidim-proposals-0.27.0.rc1 lib/decidim/api/proposals_type.rb
decidim-proposals-0.26.2 lib/decidim/api/proposals_type.rb