Class: Graphlient::Schema

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/graphlient/schema.rb

Defined Under Namespace

Classes: MissingConfigurationError

Constant Summary collapse

PATH_ERROR_MESSAGE =
'schema_path is missing. Please add it like this: `Graphlient.new(url, schema_path: YOUR_PATH)`'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http, path) ⇒ Schema

Returns a new instance of Schema.



13
14
15
16
17
18
19
# File 'lib/graphlient/schema.rb', line 13

def initialize(http, path)
  schema_source = path || http
  super(GraphQL::Client.load_schema(schema_source))

  @path = path
  @http = http
end

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



11
12
13
# File 'lib/graphlient/schema.rb', line 11

def http
  @http
end

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'lib/graphlient/schema.rb', line 11

def path
  @path
end

Instance Method Details

#dump!Object



21
22
23
24
# File 'lib/graphlient/schema.rb', line 21

def dump!
  raise MissingConfigurationError, PATH_ERROR_MESSAGE unless path
  GraphQL::Client.dump_schema(http, path)
end