Sha256: 34867f3f8fdf9b0b6020e4b2b53060c61cacf581d3382a990a9e38762629ec3d

Contents?: true

Size: 953 Bytes

Versions: 3

Compression:

Stored size: 953 Bytes

Contents

# frozen_string_literal: true

require "decidim/api/engine"

module Decidim
  # This module holds all business logic related to exposing a Public API for
  # decidim.
  module Api
    autoload :MutationType, "decidim/api/mutation_type"
    autoload :QueryType, "decidim/api/query_type"
    autoload :Schema, "decidim/api/schema"

    # This declares all the types an interface or union can resolve to. This needs
    # to be done in order to be able to have them found. This is a shortcoming of
    # graphql-ruby and the way it deals with loading types, in combination with
    # rail's infamous autoloading.
    def self.orphan_types
      Decidim.component_manifests.map(&:query_type).map(&:constantize).uniq +
        Decidim.participatory_space_manifests.map(&:query_type).map(&:constantize).uniq +
        (@orphan_types || [])
    end

    def self.add_orphan_type(type)
      @orphan_types ||= []
      @orphan_types += [type]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-api-0.11.2 lib/decidim/api.rb
decidim-api-0.11.1 lib/decidim/api.rb
decidim-api-0.11.0.pre1 lib/decidim/api.rb