Class: GraphqlAddFieldsGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/graphql_add_fields/graphql_add_fields_generator.rb

Constant Summary collapse

TYPES_MAPPING =
{
  'id' => 'String',
  'uuid' => 'String',
  'boolean' => 'Boolean',
  'float' => 'Float',
  'decimal' => 'Float',
  'integer' => 'Integer',
  'bigint' => 'Integer'
}.freeze

Instance Method Summary collapse

Instance Method Details

#create_graphql_filesObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/generators/graphql_add_fields/graphql_add_fields_generator.rb', line 20

def create_graphql_files
  return if args.blank?

  parse_args

  # Generate migration
  generate_migration(@resource, @fields_to_migration) if options.migration?

  complete_graphql_input_type if options.graphql_input_type?

  # # Graphql Type
  complete_graphql_type(@resource) if options.graphql_type?

  # # Propagation
  handle_many_to_many_fields(@resource) if options.propagation?
  add_has_many_to_models(@resource) if options.propagation?
  add_has_many_fields_to_types(@resource) if options.propagation?

  # system('bundle exec rails db:migrate') if options.migrate?
end