Class: GraphdocRuby::GraphqlJson
- Inherits:
-
Object
- Object
- GraphdocRuby::GraphqlJson
- Defined in:
- lib/graphdoc-ruby/graphql_json.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(schema_name, output_file, context = {}) ⇒ GraphqlJson
constructor
A new instance of GraphqlJson.
- #write_json ⇒ Object
Constructor Details
#initialize(schema_name, output_file, context = {}) ⇒ GraphqlJson
Returns a new instance of GraphqlJson.
15 16 17 18 19 |
# 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 |
Class Method Details
.write_schema_json ⇒ Object
5 6 7 8 9 10 11 12 13 |
# 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 |
Instance Method Details
#write_json ⇒ Object
21 22 23 24 25 26 27 28 |
# 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 |