Module: Graphql::Generators::Core
- Included in:
- Install::MutationRootGenerator, InstallGenerator, LoaderGenerator, MutationGenerator, OrmMutationsBase, RelayGenerator, TypeGeneratorBase
- Defined in:
- lib/generators/graphql/core.rb
Instance Method Summary collapse
- #create_dir(dir) ⇒ Object
- #insert_root_type(type, name) ⇒ Object
- #module_namespacing_when_supported ⇒ Object
- #schema_file_path ⇒ Object
Instance Method Details
#create_dir(dir) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/generators/graphql/core.rb', line 32 def create_dir(dir) empty_directory(dir) if ![:skip_keeps] create_file("#{dir}/.keep") end end |
#insert_root_type(type, name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/graphql/core.rb', line 17 def insert_root_type(type, name) log :add_root_type, type sentinel = /< GraphQL::Schema\s*\n/m in_root do if File.exist?(schema_file_path) inject_into_file schema_file_path, " #{type}(Types::#{name})\n", after: sentinel, verbose: false, force: false end end end |
#module_namespacing_when_supported ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/generators/graphql/core.rb', line 39 def module_namespacing_when_supported if defined?(module_namespacing) module_namespacing { yield } else yield end end |
#schema_file_path ⇒ Object
28 29 30 |
# File 'lib/generators/graphql/core.rb', line 28 def schema_file_path "#{[:directory]}/#{schema_name.underscore}.rb" end |