File: schema.rb

package info (click to toggle)
ruby-graphlient 0.5.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,648 kB
  • sloc: ruby: 1,288; makefile: 4
file content (26 lines) | stat: -rw-r--r-- 644 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'delegate'

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

    class MissingConfigurationError < StandardError; end

    alias graphql_schema __getobj__

    attr_reader :http, :path

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

      @path = path
      @http = http
    end

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