class GraphqlUtil::Schema

Public Class Methods

new(http, path:) click to toggle source

Initialize the GraphqlUtil::Schema to generate or retrieve the GraphQL Schema dump

@param [GraphqlUtil::Http] http HTTP Client instance @param [String] path Path to the client Class

# File lib/graphql_util/schema.rb, line 13
def initialize(http, path:)
  @http = http
  @path = path
end

Public Instance Methods

load_schema() click to toggle source

Loads the GraphQL Endpoint Introspection Schema from a dumped file if present, or dumps itself if needed

@return [Class] GraphQL Schema

# File lib/graphql_util/schema.rb, line 23
def load_schema
  if !File.exist?(@path)
    schema_dir = File.dirname(@path)
    FileUtils.mkdir_p(schema_dir) unless File.directory?(schema_dir)
    GraphQL::Client.dump_schema(@http, @path)
  end

  GraphQL::Client.load_schema(@path)
end