Class: NulogyGraphqlApi::Tasks::SchemaGenerator
- Inherits:
-
Object
- Object
- NulogyGraphqlApi::Tasks::SchemaGenerator
- Defined in:
- lib/nulogy_graphql_api/tasks/schema_generator.rb
Instance Method Summary collapse
- #check_changes ⇒ Object
- #generate_schema ⇒ Object
-
#initialize(schema_output_path, schema, context: {}) ⇒ SchemaGenerator
constructor
A new instance of SchemaGenerator.
- #write_schema_to_file ⇒ Object
Constructor Details
#initialize(schema_output_path, schema, context: {}) ⇒ SchemaGenerator
Returns a new instance of SchemaGenerator.
4 5 6 7 8 |
# File 'lib/nulogy_graphql_api/tasks/schema_generator.rb', line 4 def initialize(schema_output_path, schema, context: {}) @schema_output_path = schema_output_path @schema = schema @context = context end |
Instance Method Details
#check_changes ⇒ Object
16 17 18 19 20 |
# File 'lib/nulogy_graphql_api/tasks/schema_generator.rb', line 16 def check_changes return if old_schema.blank? SchemaChangesChecker.new.check_changes(old_schema, generate_schema) end |
#generate_schema ⇒ Object
10 11 12 13 14 |
# File 'lib/nulogy_graphql_api/tasks/schema_generator.rb', line 10 def generate_schema visible_schema = Class.new(@schema) visible_schema.use(GraphQL::Schema::AlwaysVisible) visible_schema.to_definition(context: @context) end |
#write_schema_to_file ⇒ Object
22 23 24 25 |
# File 'lib/nulogy_graphql_api/tasks/schema_generator.rb', line 22 def write_schema_to_file File.write(@schema_output_path, generate_schema) puts Rainbow("\nSuccessfully updated #{@schema_output_path}").green end |