Module: GraphQLDocs
- Defined in:
- lib/graphql-docs.rb,
lib/graphql-docs/parser.rb,
lib/graphql-docs/helpers.rb,
lib/graphql-docs/version.rb,
lib/graphql-docs/renderer.rb,
lib/graphql-docs/generator.rb,
lib/graphql-docs/configuration.rb
Defined Under Namespace
Modules: Configuration, Helpers Classes: Generator, Parser, Renderer
Constant Summary collapse
- VERSION =
'1.9.0'.freeze
Class Method Summary collapse
Class Method Details
.build(options) ⇒ Object
16 17 18 19 20 21 22 23 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/graphql-docs.rb', line 16 def build() # do not let user provided values overwrite every single value %i(templates landing_pages).each do |opt| if .key?(opt) GraphQLDocs::Configuration::GRAPHQLDOCS_DEFAULTS[opt].each_pair do |key, value| unless [opt].key?(key) [opt][key] = value end end end end = GraphQLDocs::Configuration::GRAPHQLDOCS_DEFAULTS.merge() filename = [:filename] schema = [:schema] if !filename.nil? && !schema.nil? raise ArgumentError, 'Pass in `filename` or `schema`, but not both!' end if filename.nil? && schema.nil? raise ArgumentError, 'Pass in either `filename` or `schema`' end if filename unless filename.is_a?(String) raise TypeError, "Expected `String`, got `#{filename.class}`" end unless File.exist?(filename) raise ArgumentError, "#{filename} does not exist!" end schema = File.read(filename) else if !schema.is_a?(String) && !schema.is_a?(GraphQL::Schema) raise TypeError, "Expected `String` or `GraphQL::Schema`, got `#{schema.class}`" end schema = schema end parser = GraphQLDocs::Parser.new(schema, ) parsed_schema = parser.parse generator = GraphQLDocs::Generator.new(parsed_schema, ) generator.generate end |