module Decidim::Assemblies::QueryExtensions

This module's job is to extend the API with custom fields related to decidim-assemblies.

Public Class Methods

included(type) click to toggle source

Public: Extends a type with `decidim-assemblies`'s fields.

type - A GraphQL::BaseType to extend.

Returns nothing.

# 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 let's you filter the results", required: false
    argument :order, Decidim::ParticipatoryProcesses::ParticipatoryProcessInputSort, "This argument let's you order the results", required: false
  end

  type.field :assembly,
             Decidim::Assemblies::AssemblyType,
             null: true,
             description: "Finds a assembly" do
    argument :id, GraphQL::Types::ID, "The ID of the participatory space", required: false
  end
end

Public Instance Methods

assemblies(filter: {}, order: {}) click to toggle source
# 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: manifest).call(object, { filter: filter, order: order }, context)
end
assemblies_type(id:) click to toggle source
# File lib/decidim/assemblies/query_extensions.rb, line 41
def assemblies_type(id:)
  Decidim::AssembliesType.find_by(
    organization: context[:current_organization],
    id: id
  )
end
assemblies_types(*) click to toggle source
# File lib/decidim/assemblies/query_extensions.rb, line 35
def assemblies_types(*)
  Decidim::AssembliesType.where(
    organization: context[:current_organization]
  )
end
assembly(id: nil) click to toggle source
# 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: manifest).call(object, { id: id }, context)
end