Sha256: 0de386b4920fff814ec222482fc0aaeded806a7347514c54f8f591a147eb1125

Contents?: true

Size: 1.72 KB

Versions: 37

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

module Decidim
  module Consultations
    # This module's job is to extend the API with custom fields related to
    # decidim-assemblies.
    module QueryExtensions
      # Public: Extends a type with `decidim-assemblies`'s fields.
      #
      # type - A GraphQL::BaseType to extend.
      #
      # Returns nothing.
      def self.included(type)
        type.field :consultations,
                   [Decidim::Consultations::ConsultationType],
                   null: true,
                   description: "Lists all consultations" 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 :consultation,
                   Decidim::Consultations::ConsultationType,
                   null: true,
                   description: "Finds a consultation" do
          argument :id, GraphQL::Types::ID, "The ID of the participatory space", required: false
        end
      end

      def consultations(filter: {}, order: {})
        manifest = Decidim.participatory_space_manifests.select { |m| m.name == :consultations }.first

        Decidim::Core::ParticipatorySpaceListBase.new(manifest: manifest).call(object, { filter: filter, order: order }, context)
      end

      def consultation(id: nil)
        manifest = Decidim.participatory_space_manifests.select { |m| m.name == :consultations }.first

        Decidim::Core::ParticipatorySpaceFinderBase.new(manifest: manifest).call(object, { id: id }, context)
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
decidim-consultations-0.27.9 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.27.8 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.27.7 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.27.6 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.26.10 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.26.9 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.27.5 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.26.8 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.27.4 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.27.3 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.26.7 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.26.5 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.27.2 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.27.1 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.26.4 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.27.0 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.26.3 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.27.0.rc2 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.27.0.rc1 lib/decidim/consultations/query_extensions.rb
decidim-consultations-0.26.2 lib/decidim/consultations/query_extensions.rb