Sha256: 83008106b57ba5175a1357524d72b47a2ca041edb511c46d757e5c2e86593f28

Contents?: true

Size: 1.27 KB

Versions: 17

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Decidim
  module Core
    ParticipatorySpaceInterface = GraphQL::InterfaceType.define do
      name "ParticipatorySpaceInterface"
      description "The interface that all participatory spaces should implement."

      field :id, !types.ID, "The participatory space's unique ID"

      field :title, !TranslatedFieldType, "The name of this participatory space."

      field :components, types[ComponentInterface] do
        description "Lists the components this space contains."

        resolve ->(participatory_space, _args, _ctx) {
                  Decidim::Component.where(
                    participatory_space: participatory_space
                  ).published
                }
      end

      field :stats, types[Decidim::Core::StatisticType] do
        resolve ->(participatory_space, _args, _ctx) {
          published_components = Component.where(participatory_space: participatory_space).published

          stats = Decidim.component_manifests.map do |component_manifest|
            component_manifest.stats.with_context(published_components).map { |name, data| [name, data] }.flatten
          end

          stats.reject(&:empty?)
        }
      end

      resolve_type ->(obj, _ctx) { obj.manifest.query_type.constantize }
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
decidim-core-0.15.2 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.15.1 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.15.0 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.14.4 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.14.3 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.14.2 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.14.1 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.13.1 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.12.2 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.13.0 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.12.1 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.13.0.pre1 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.12.0 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.11.2 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.12.0.pre lib/decidim/api/participatory_space_interface.rb
decidim-core-0.11.1 lib/decidim/api/participatory_space_interface.rb
decidim-core-0.11.0.pre1 lib/decidim/api/participatory_space_interface.rb