Method: Graphiti::Configuration#initialize

Defined in:
lib/graphiti/configuration.rb

#initializeConfiguration

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set defaults

API:

  • private



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/graphiti/configuration.rb', line 24

def initialize
  @raise_on_missing_sideload = true
  @concurrency = false
  @respond_to = [:json, :jsonapi, :xml]
  @links_on_demand = false
  @pagination_links_on_demand = false
  @pagination_links = false
  @typecast_reads = true
  self.debug = ENV.fetch("GRAPHITI_DEBUG", true)
  self.debug_models = ENV.fetch("GRAPHITI_DEBUG_MODELS", false)

  # FIXME: Don't duplicate graphiti-rails efforts
  if defined?(::Rails.root) && (root = ::Rails.root)
    config_file = root.join(".graphiticfg.yml")
    if config_file.exist?
      cfg = YAML.load_file(config_file)
      @schema_path = root.join("public#{cfg["namespace"]}/schema.json")
    else
      @schema_path = root.join("public/schema.json")
    end

    if (logger = ::Rails.logger)
      self.debug = logger.level.zero?
      Graphiti.logger = logger
    end
  end
end