Sha256: e34dd3e6885a0faf8c6763f4ade4c17941b7ec59a1c2813c059125d8e44e2360

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

require 'graphql-docs/client'
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'
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 = GraphQLDocs::Generator.new(parsed_schema, options)

      generator.generate
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
graphql-docs-0.4.1 lib/graphql-docs.rb
graphql-docs-0.4.0 lib/graphql-docs.rb
graphql-docs-0.3.0 lib/graphql-docs.rb
graphql-docs-0.2.2 lib/graphql-docs.rb
graphql-docs-0.2.1 lib/graphql-docs.rb
graphql-docs-0.2.0 lib/graphql-docs.rb
graphql-docs-0.1.1 lib/graphql-docs.rb