Class: Ibrain::Graphql::ResolverGenerator
- Inherits:
-
ResolversGenerator
- Object
- Rails::Generators::Base
- ResolversGenerator
- Ibrain::Graphql::ResolverGenerator
- Defined in:
- lib/generators/ibrain/graphql/resolver_generator.rb
Overview
TODO: What other options should be supported?
Instance Attribute Summary
Attributes inherited from ResolversGenerator
#field_name, #file_name, #model_name, #resolver_name
Instance Method Summary collapse
Methods inherited from ResolversGenerator
Methods included from Core
#create_dir, #create_mutation_root_type, #create_repository_root_type, #create_resolver_root_type, included, #insert_root_type, #module_namespacing_when_supported, #schema_file_path
Constructor Details
This class inherits a constructor from Ibrain::Graphql::ResolversGenerator
Instance Method Details
#create_resolver_file ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/ibrain/graphql/resolver_generator.rb', line 16 def create_resolver_file if @behavior == :revoke log :gsub, "#{[:directory]}/types/query_type.rb" else create_resolver_root_type end if [:model].present? system("bundle exec rails generate ibrain:graphql:object #{[:model].underscore}") end template "resolver.erb", "#{[:directory]}/resolvers/#{file_name}.rb" return unless ::Ibrain::Config.is_auto_append_mutation in_root do gsub_file "#{[:directory]}/types/query_type.rb", / \# TODO: Add Resolvers as fields\s*\n/m, "" inject_into_file "#{[:directory]}/types/query_type.rb", "\n field :#{field_name}, resolver: Resolvers::#{resolver_name} \n ", before: "end\nend", verbose: true, force: true end end |