class Graphiti::Configuration
Attributes
before_sideload[RW]
cache_rendering[W]
concurrency[RW]
@return [Boolean] Concurrently fetch sideloads?
Defaults to false OR if classes are cached (Rails-only)
context_for_endpoint[RW]
debug[R]
debug_models[R]
links_on_demand[RW]
pagination_links[RW]
pagination_links_on_demand[RW]
raise_on_missing_sideload[RW]
@return [Boolean] Should we raise when the client requests a relationship not defined on the server?
Defaults to true.
raise_on_missing_sidepost[RW]
respond_to[RW]
schema_path[W]
typecast_reads[RW]
Public Class Methods
new()
click to toggle source
Set defaults @api private
# File lib/graphiti/configuration.rb, line 27 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 @raise_on_missing_sidepost = true @cache_rendering = false 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.debug? && debug Graphiti.logger = logger end end end
Public Instance Methods
cache_rendering?()
click to toggle source
# File lib/graphiti/configuration.rb, line 57 def cache_rendering? use_caching = @cache_rendering && Graphiti.cache.respond_to?(:fetch) use_caching.tap do |use| if @cache_rendering && !Graphiti.cache&.respond_to?(:fetch) raise "You must configure a cache store in order to use cache_rendering. Set Graphiti.cache = Rails.cache, for example." end end end
debug=(val)
click to toggle source
# File lib/graphiti/configuration.rb, line 71 def debug=(val) @debug = val Debugger.enabled = val end
debug_models=(val)
click to toggle source
# File lib/graphiti/configuration.rb, line 76 def debug_models=(val) @debug_models = val Debugger.debug_models = val end
schema_path()
click to toggle source
# File lib/graphiti/configuration.rb, line 67 def schema_path @schema_path ||= raise("No schema_path defined! Set Graphiti.config.schema_path to save your schema.") end
with_option(key, value) { || ... }
click to toggle source
# File lib/graphiti/configuration.rb, line 81 def with_option(key, value) original = send(key) send(:"#{key}=", value) yield ensure send(:"#{key}=", original) end