Sha256: 1d751d7f6e022341b5555204a7289c9638edb450b64f6cd6ee0084b9934d91a9

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

require 'graphql-docs/client'
require 'graphql-docs/configuration'
require 'graphql-docs/generator'
require 'graphql-docs/parser'
require 'graphql-docs/renderer'
require 'graphql-docs/version'

begin
  require 'awesome_print'
rescue LoadError; end

module GraphQLDocs
  class << self
    def build(options)
      options = GraphQLDocs::Configuration::GRAPHQLDOCS_DEFAULTS.merge(options)

      if options[:url].nil? && options[:path].nil?
        fail ArgumentError, 'No :url or :path provided!'
      end

      if !options[:url].nil? && !options[:path].nil?
        fail ArgumentError, 'You can\'t pass both :url and :path!'
      end

      if options[:url]
        client = GraphQLDocs::Client.new(options)
        response = client.fetch
      else
        response = File.read(options[:path])
      end

      parser = GraphQLDocs::Parser.new(response, options)
      parsed_schema = parser.parse

      generator = Generator.new(parsed_schema, options)

      generator.generate
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql-docs-0.1.0 lib/graphql-docs.rb