Module: Decidim::ParticipatoryProcesses::QueryExtensions
- Defined in:
- decidim-participatory_processes/lib/decidim/participatory_processes/query_extensions.rb
Overview
This module’s job is to extend the API with custom fields related to decidim-participatory_processes.
Class Method Summary collapse
-
.included(type) ⇒ Object
Public: Extends a type with ‘decidim-participatory_processes`’s fields.
Instance Method Summary collapse
- #participatory_process(id: nil, slug: nil) ⇒ Object
- #participatory_process_group(id:) ⇒ Object
- #participatory_process_groups ⇒ Object
- #participatory_process_type(id:) ⇒ Object
- #participatory_process_types ⇒ Object
- #participatory_processes(filter: {}, order: {}) ⇒ Object
Class Method Details
.included(type) ⇒ Object
Public: Extends a type with ‘decidim-participatory_processes`’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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'decidim-participatory_processes/lib/decidim/participatory_processes/query_extensions.rb', line 13 def self.included(type) type.field :participatory_processes, [Decidim::ParticipatoryProcesses::ParticipatoryProcessType], null: true, description: "Lists all participatory_processes" 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 :participatory_process, Decidim::ParticipatoryProcesses::ParticipatoryProcessType, null: true, description: "Finds a participatory_process" do argument :id, GraphQL::Types::ID, "The ID of the participatory space", required: false argument :slug, String, "The slug of the participatory process", required: false end type.field :participatory_process_groups, [ParticipatoryProcessGroupType], null: false, description: "Lists all participatory process groups" type.field :participatory_process_group, ParticipatoryProcessGroupType, null: true do description "Finds a participatory process group" argument :id, GraphQL::Types::ID, required: true, description: "The ID of the Participatory process group" end type.field :participatory_process_types, [ParticipatoryProcessTypeType], null: false, description: "List all participatory process types" type.field :participatory_process_type, ParticipatoryProcessTypeType, null: true do description "Finds a participatory process type" argument :id, GraphQL::Types::ID, required: true, description: "The ID of the participatory process type" end end |
Instance Method Details
#participatory_process(id: nil, slug: nil) ⇒ Object
54 55 56 57 |
# File 'decidim-participatory_processes/lib/decidim/participatory_processes/query_extensions.rb', line 54 def participatory_process(id: nil, slug: nil) manifest = Decidim.participatory_space_manifests.select { |m| m.name == :participatory_processes }.first Decidim::Core::ParticipatorySpaceFinderBase.new(manifest:).call(object, { id:, slug: }, context) end |
#participatory_process_group(id:) ⇒ Object
65 66 67 68 69 70 |
# File 'decidim-participatory_processes/lib/decidim/participatory_processes/query_extensions.rb', line 65 def participatory_process_group(id:) Decidim::ParticipatoryProcessGroup.find_by( organization: context[:current_organization], id: ) end |
#participatory_process_groups ⇒ Object
59 60 61 62 63 |
# File 'decidim-participatory_processes/lib/decidim/participatory_processes/query_extensions.rb', line 59 def participatory_process_groups(*) Decidim::ParticipatoryProcessGroup.where( organization: context[:current_organization] ) end |
#participatory_process_type(id:) ⇒ Object
78 79 80 81 82 83 |
# File 'decidim-participatory_processes/lib/decidim/participatory_processes/query_extensions.rb', line 78 def participatory_process_type(id:) Decidim::ParticipatoryProcessType.find_by( organization: context[:current_organization], id: ) end |
#participatory_process_types ⇒ Object
72 73 74 75 76 |
# File 'decidim-participatory_processes/lib/decidim/participatory_processes/query_extensions.rb', line 72 def participatory_process_types(*) Decidim::ParticipatoryProcessType.where( organization: context[:current_organization] ) end |
#participatory_processes(filter: {}, order: {}) ⇒ Object
49 50 51 52 |
# File 'decidim-participatory_processes/lib/decidim/participatory_processes/query_extensions.rb', line 49 def participatory_processes(filter: {}, order: {}) manifest = Decidim.participatory_space_manifests.select { |m| m.name == :participatory_processes }.first Decidim::Core::ParticipatorySpaceListBase.new(manifest:).call(object, { filter:, order: }, context) end |