Module: Decidim::ParticipatoryProcesses::QueryExtensions

Defined in:
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

Instance Method Summary collapse

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
# File 'lib/decidim/participatory_processes/query_extensions.rb', line 13

def self.included(type)
  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_group(id:) ⇒ Object



39
40
41
42
43
44
# File 'lib/decidim/participatory_processes/query_extensions.rb', line 39

def participatory_process_group(id:)
  Decidim::ParticipatoryProcessGroup.find_by(
    organization: context[:current_organization],
    id:
  )
end

#participatory_process_groupsObject



33
34
35
36
37
# File 'lib/decidim/participatory_processes/query_extensions.rb', line 33

def participatory_process_groups(*)
  Decidim::ParticipatoryProcessGroup.where(
    organization: context[:current_organization]
  )
end

#participatory_process_type(id:) ⇒ Object



52
53
54
55
56
57
# File 'lib/decidim/participatory_processes/query_extensions.rb', line 52

def participatory_process_type(id:)
  Decidim::ParticipatoryProcessType.find_by(
    organization: context[:current_organization],
    id:
  )
end

#participatory_process_typesObject



46
47
48
49
50
# File 'lib/decidim/participatory_processes/query_extensions.rb', line 46

def participatory_process_types(*)
  Decidim::ParticipatoryProcessType.where(
    organization: context[:current_organization]
  )
end