Sha256: 6175fa46e066a9f2bdcb10ad62803617789cf896918b1f2538733849bac5c9bd
Contents?: true
Size: 1.38 KB
Versions: 17
Compression:
Stored size: 1.38 KB
Contents
# rubocop:disable Style/FileName require 'graphql-docs/helpers' require 'graphql-docs/renderer' require 'graphql-docs/configuration' require 'graphql-docs/generator' require 'graphql-docs/parser' require 'graphql-docs/version' begin require 'awesome_print' require 'pry' rescue LoadError; end module GraphQLDocs class << self def build(options) options = GraphQLDocs::Configuration::GRAPHQLDOCS_DEFAULTS.merge(options) filename = options[:filename] schema = options[: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 unless schema.is_a?(String) raise TypeError, "Expected `String`, got `#{schema.class}`" end schema = schema end parser = GraphQLDocs::Parser.new(schema, options) parsed_schema = parser.parse generator = GraphQLDocs::Generator.new(parsed_schema, options) generator.generate end end end
Version data entries
17 entries across 17 versions & 1 rubygems