class GraphdocRuby::Config
Attributes
endpoint[R]
Required: <String> GraphQL endpoint url or dumped schema.json path.
executable_path[RW]
Optional: <String> Executable path of `graphdoc`. (default: `Bundler.which('graphdoc')`)
graphql_context[RW]
Optional: <Proc> Context of your graphql. (default: -> {})
graphql_query[RW]
Optional: <Proc> Query of your graphql. (default: -> {})
mtime[R]
no doc
output_directory[R]
Optional: <String> Output path for `graphdoc`. If you disabled run_time_generation
, this value must be customized. (default: `File.join(Dir.mktmpdir, 'graphdoc')`)
overwrite[RW]
Optional: <Boolean> Overwrite files if generated html already exist. (default: true)
run_time_generation[RW]
Optional: <Boolean> Generate html with graphdoc on the first access. (default: true)
schema_name[RW]
Optional: <String> Schema name of your graphql-ruby. It is necessary when generating schema.json. (default: nil)
Public Class Methods
new()
click to toggle source
# File lib/graphdoc-ruby/config.rb, line 51 def initialize self.endpoint = nil self.executable_path = Bundler.which('graphdoc') self.output_directory = default_output_directory self.overwrite = true self.run_time_generation = true self.schema_name = nil self.graphql_context = -> {} self.graphql_query = -> {} @use_temporary_output_directory = true @mtime = Time.now end
Public Instance Methods
assert_configuration!()
click to toggle source
# File lib/graphdoc-ruby/config.rb, line 84 def assert_configuration! unless endpoint raise InvalidConfiguration, "(endpoint: '#{endpoint}') must be GraphQL endpoint url or dumped schema.json path." end if @use_temporary_output_directory && !run_time_generation raise InvalidConfiguration, 'If you disabled run_time_generation, static `output_directory` must be set.' end unless File.executable?(executable_path) raise InvalidConfiguration, '`graphdoc` not found. Please install graphdoc (npm install -g @2fd/graphdoc)' end end
endpoint=(value)
click to toggle source
# File lib/graphdoc-ruby/config.rb, line 65 def endpoint=(value) @endpoint = value.to_s end
evaluate_graphql_context()
click to toggle source
# File lib/graphdoc-ruby/config.rb, line 74 def evaluate_graphql_context hash = self.graphql_context.call hash if hash.is_a?(Hash) end
evaluate_graphql_query()
click to toggle source
# File lib/graphdoc-ruby/config.rb, line 79 def evaluate_graphql_query hash = self.graphql_query.call hash if hash.is_a?(Hash) end
output_directory=(value)
click to toggle source
# File lib/graphdoc-ruby/config.rb, line 69 def output_directory=(value) @output_directory = value.to_s @use_temporary_output_directory = false end
Private Instance Methods
default_output_directory()
click to toggle source
# File lib/graphdoc-ruby/config.rb, line 100 def default_output_directory File.join(Dir.mktmpdir, 'graphdoc') end