Module: Graphql::Generators::Core
- Included in:
- InstallGenerator, MutationGenerator
- Defined in:
- lib/generators/graphql/core.rb
Instance Method Summary collapse
- #create_dir(dir) ⇒ Object
- #create_mutation_root_type ⇒ Object
- #insert_root_type(type, name) ⇒ Object
- #schema_file_path ⇒ Object
Instance Method Details
#create_dir(dir) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/generators/graphql/core.rb', line 26 def create_dir(dir) empty_directory(dir) if ![:skip_keeps] create_file("#{dir}/.keep") end end |
#create_mutation_root_type ⇒ Object
16 17 18 19 20 |
# File 'lib/generators/graphql/core.rb', line 16 def create_mutation_root_type create_dir("app/graphql/mutations") template("mutation_type.erb", "app/graphql/types/mutation_type.rb", { skip: true }) insert_root_type('mutation', 'MutationType') end |
#insert_root_type(type, name) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/generators/graphql/core.rb', line 7 def insert_root_type(type, name) log :add_root_type, type sentinel = /GraphQL\:\:Schema\.define do\s*\n/m in_root do inject_into_file schema_file_path, " #{type}(Types::#{name})\n", after: sentinel, verbose: false, force: false end end |
#schema_file_path ⇒ Object
22 23 24 |
# File 'lib/generators/graphql/core.rb', line 22 def schema_file_path "app/graphql/#{schema_name.underscore}.rb" end |