Module: Decidim::Assemblies::QueryExtensions
- Defined in:
- lib/decidim/assemblies/query_extensions.rb
Overview
This module’s job is to extend the API with custom fields related to decidim-assemblies.
Class Method Summary collapse
-
.included(type) ⇒ Object
Public: Extends a type with ‘decidim-assemblies`’s fields.
Instance Method Summary collapse
- #assemblies(filter: {}, order: {}) ⇒ Object
- #assemblies_type(id:) ⇒ Object
- #assemblies_types ⇒ Object
- #assembly(id: nil) ⇒ Object
Class Method Details
.included(type) ⇒ Object
Public: Extends a type with ‘decidim-assemblies`’s fields.
type - A GraphQL::BaseType to extend.
Returns nothing.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/decidim/assemblies/query_extensions.rb', line 13 def self.included(type) type.field :assemblies_types, [AssembliesTypeType], null: false, description: "Lists all assemblies types" type.field :assemblies_type, AssembliesTypeType, null: true, description: "Finds an assemblies type group" do argument :id, GraphQL::Types::ID, description: "The ID of the Assemblies type", required: true end type.field :assemblies, [Decidim::Assemblies::AssemblyType], null: true, description: "Lists all assemblies" do argument :filter, Decidim::ParticipatoryProcesses::ParticipatoryProcessInputFilter, "This argument lets you filter the results", required: false argument :order, Decidim::ParticipatoryProcesses::ParticipatoryProcessInputSort, "This argument lets you order the results", required: false end type.field :assembly, Decidim::Assemblies::AssemblyType, null: true, description: "Finds an assembly" do argument :id, GraphQL::Types::ID, "The ID of the participatory space", required: false end end |
Instance Method Details
#assemblies(filter: {}, order: {}) ⇒ Object
48 49 50 51 |
# File 'lib/decidim/assemblies/query_extensions.rb', line 48 def assemblies(filter: {}, order: {}) manifest = Decidim.participatory_space_manifests.select { |m| m.name == :assemblies }.first Decidim::Core::ParticipatorySpaceListBase.new(manifest:).call(object, { filter:, order: }, context) end |
#assemblies_type(id:) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/decidim/assemblies/query_extensions.rb', line 41 def assemblies_type(id:) Decidim::AssembliesType.find_by( organization: context[:current_organization], id: ) end |
#assemblies_types ⇒ Object
35 36 37 38 39 |
# File 'lib/decidim/assemblies/query_extensions.rb', line 35 def assemblies_types(*) Decidim::AssembliesType.where( organization: context[:current_organization] ) end |
#assembly(id: nil) ⇒ Object
53 54 55 56 |
# File 'lib/decidim/assemblies/query_extensions.rb', line 53 def assembly(id: nil) manifest = Decidim.participatory_space_manifests.select { |m| m.name == :assemblies }.first Decidim::Core::ParticipatorySpaceFinderBase.new(manifest:).call(object, { id: }, context) end |