Sha256: 6647a4d479a5efa4b18105a2c6dbab0c93a373db74e5704ad431011228e3986b

Contents?: true

Size: 1.1 KB

Versions: 37

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Decidim
  module Core
    # An abstract resolver for the GraphQL component endpoints inside a participatory_space.
    # Used in the keyword "components", ie:
    #
    # participatoryProcesses {
    #   components {...}
    # }
    #
    # Needs to be extended and add arguments.
    #
    # This is used by ParticipatorySpaceInterface to apply filter/orders when
    # searching raw components. When listing properly defined components,
    # use ComponentListBase instead
    class ComponentList
      include NeedsApiFilterAndOrder
      include NeedsApiDefaultOrder
      attr_reader :model_class

      def initialize
        @model_class = Component
      end

      def call(participatory_space, args, _ctx)
        @query = Decidim::Component
        # remove default ordering if custom order required
        @query = @query.unscoped if args[:order]
        @query = @query.where(participatory_space: participatory_space).published
        add_filter_keys(args[:filter])
        add_order_keys(args[:order].to_h)
        add_default_order
        @query
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

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