Sha256: aec3ef344596e01cc3930faf17147fb376edef3f0204946272ad4cd26c3e6aa8

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    # 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.define(type)
        type.field :assembliesTypes do
          type !types[AssembliesTypeType]
          description "Lists all assemblies types"

          resolve lambda { |_obj, _args, ctx|
            Decidim::AssembliesType.where(
              organization: ctx[:current_organization]
            )
          }
        end

        type.field :assembliesType do
          type AssembliesTypeType
          description "Finds an assemblies type group"
          argument :id, !types.ID, "The ID of the Assemblies type"

          resolve lambda { |_obj, args, ctx|
            Decidim::AssembliesType.find_by(
              organization: ctx[:current_organization],
              id: args[:id]
            )
          }
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-assemblies-0.23.6 lib/decidim/assemblies/query_extensions.rb
decidim-assemblies-0.23.5 lib/decidim/assemblies/query_extensions.rb
decidim-assemblies-0.23.4 lib/decidim/assemblies/query_extensions.rb
decidim-assemblies-0.23.3 lib/decidim/assemblies/query_extensions.rb
decidim-assemblies-0.23.2 lib/decidim/assemblies/query_extensions.rb
decidim-assemblies-0.23.1 lib/decidim/assemblies/query_extensions.rb
decidim-assemblies-0.23.1.rc1 lib/decidim/assemblies/query_extensions.rb
decidim-assemblies-0.23.0 lib/decidim/assemblies/query_extensions.rb
decidim-assemblies-0.22.0 lib/decidim/assemblies/query_extensions.rb
decidim-assemblies-0.21.0 lib/decidim/assemblies/query_extensions.rb