Sha256: de87a3442b4babf240e020fc55ad5174b80ded8fdc82142bb20ffef5bd5fa932

Contents?: true

Size: 989 Bytes

Versions: 1

Compression:

Stored size: 989 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This module's job is to extend the API with custom fields related to
  # decidim-core.
  module QueryExtensions
    # Public: Extends a type with `decidim-core`'s fields.
    #
    # type - A GraphQL::BaseType to extend.
    #
    # Returns nothing.
    def self.extend!(type)
      type.define do
        field :processes do
          type !types[ProcessType]
          description "Lists all processes."

          resolve ->(_obj, _args, ctx) {
            OrganizationParticipatoryProcesses.new(ctx[:current_organization])
          }
        end

        field :session do
          type SessionType
          description "Return's information about the logged in user"

          resolve ->(_obj, _args, ctx) {
            ctx[:current_user]
          }
        end

        field :decidim, DecidimType, "Decidim's framework properties." do
          resolve ->(_obj, _args, _ctx) { Decidim }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-core-0.2.0 lib/decidim/query_extensions.rb