Class: GraphQL::Doctor::Runtime::SchemaLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/doctor/runtime/schema_loader.rb

Class Method Summary collapse

Class Method Details

.load(config, root: Dir.pwd) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/graphql/doctor/runtime/schema_loader.rb', line 7

def self.load(config, root: Dir.pwd)
  boot_environment(config["require"], root)

  name = config["schema"]
  raise Error, "Configuration key `schema` is required" unless name && !name.strip.empty?

  schema = resolve_schema(name)
  raise Error, "Configured schema `#{name}` is not a GraphQL::Schema subclass" unless graphql_schema?(schema)

  schema
rescue StandardError, LoadError, SyntaxError => e
  raise Error, "GQLD101: Failed to boot schema: #{e.message}"
end