Class: GraphqlUtil::Schema
- Inherits:
-
Object
- Object
- GraphqlUtil::Schema
- Defined in:
- lib/graphql_util/schema.rb
Instance Method Summary collapse
-
#initialize(http, path:) ⇒ Schema
constructor
Initialize the GraphqlUtil::Schema to generate or retrieve the GraphQL Schema dump.
-
#load_schema ⇒ Class
Loads the GraphQL Endpoint Introspection Schema from a dumped file if present, or dumps itself if needed.
Constructor Details
#initialize(http, path:) ⇒ Schema
Initialize the GraphqlUtil::Schema to generate or retrieve the GraphQL Schema dump
13 14 15 16 |
# File 'lib/graphql_util/schema.rb', line 13 def initialize(http, path:) @http = http @path = path end |
Instance Method Details
#load_schema ⇒ Class
Loads the GraphQL Endpoint Introspection Schema from a dumped file if present, or dumps itself if needed
23 24 25 26 27 28 29 30 31 |
# 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 |