class Graphql::Generators::MutationGenerator
TODO: What other options should be supported?
@example Generate a `GraphQL::Schema::RelayClassicMutation` by name
rails g graphql:mutation CreatePostMutation
Public Instance Methods
create_mutation_file()
click to toggle source
# File lib/generators/graphql/mutation_generator.rb, line 18 def create_mutation_file template "mutation.erb", File.join(options[:directory], "/mutations/", class_path, "#{file_name}.rb") sentinel = /class .*MutationType\s*<\s*[^\s]+?\n/m in_root do path = "#{options[:directory]}/types/mutation_type.rb" invoke "graphql:install:mutation_root" unless File.exist?(path) inject_into_file "#{options[:directory]}/types/mutation_type.rb", " field :#{file_name}, mutation: Mutations::#{class_name}\n", after: sentinel, verbose: false, force: false end end