Class: Decidim::Core::ComponentList
- Inherits:
-
Object
- Object
- Decidim::Core::ComponentList
- Includes:
- NeedsApiDefaultOrder, NeedsApiFilterAndOrder
- Defined in:
- lib/decidim/api/functions/component_list.rb
Overview
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
Instance Attribute Summary collapse
-
#model_class ⇒ Object
readonly
Returns the value of attribute model_class.
Instance Method Summary collapse
- #call(participatory_space, args, _ctx) ⇒ Object
-
#initialize ⇒ ComponentList
constructor
A new instance of ComponentList.
Methods included from NeedsApiFilterAndOrder
#add_filter_keys, #add_order_keys
Constructor Details
#initialize ⇒ ComponentList
Returns a new instance of ComponentList.
22 23 24 |
# File 'lib/decidim/api/functions/component_list.rb', line 22 def initialize @model_class = Component end |
Instance Attribute Details
#model_class ⇒ Object (readonly)
Returns the value of attribute model_class.
20 21 22 |
# File 'lib/decidim/api/functions/component_list.rb', line 20 def model_class @model_class end |
Instance Method Details
#call(participatory_space, args, _ctx) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/decidim/api/functions/component_list.rb', line 26 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 |