class GraphdocRuby::GraphqlJson
Public Class Methods
new(schema_name, output_file, context = {})
click to toggle source
# File lib/graphdoc-ruby/graphql_json.rb, line 15 def initialize(schema_name, output_file, context = {}) @schema_name = schema_name @output_file = output_file @context = context end
write_schema_json()
click to toggle source
# File lib/graphdoc-ruby/graphql_json.rb, line 5 def self.write_schema_json context = GraphdocRuby.config.evaluate_graphql_context || {} new( GraphdocRuby.config.schema_name, GraphdocRuby.config.endpoint, context ).write_json end
Public Instance Methods
write_json()
click to toggle source
# File lib/graphdoc-ruby/graphql_json.rb, line 21 def write_json json = schema.to_json(context: @context) directory = File.dirname(@output_file) FileUtils.mkdir_p(directory) File.write(@output_file, json) end
Private Instance Methods
schema()
click to toggle source
# File lib/graphdoc-ruby/graphql_json.rb, line 32 def schema @schema ||= Object.const_get(@schema_name.to_s) rescue raise GraphdocRuby::Config::InvalidConfiguration, "(schema_name: #{@schema_name}) must be GraphQL Schema" end