lib/souls/generate/mutation.rb in souls-0.21.1 vs lib/souls/generate/mutation.rb in souls-0.21.2

- old
+ new

@@ -192,19 +192,22 @@ end file_path end def update_mutation class_name: "souls" + file_path = "./app/graphql/mutations/#{class_name}/update_#{class_name}.rb" + return "Mutation already exist! #{file_path}" if File.exist? file_path update_mutation_head class_name: class_name relation_params = update_mutation_params class_name: class_name update_mutation_after_params class_name: class_name, relation_params: relation_params update_mutation_end class_name: class_name end # 3. Mutation - Delete def delete_mutation class_name: "souls" file_path = "./app/graphql/mutations/#{class_name}/delete_#{class_name}.rb" + return "Mutation already exist! #{file_path}" if File.exist? file_path File.open(file_path, "w") do |f| f.write <<~EOS module Mutations module #{class_name.camelize} class Delete#{class_name.camelize} < BaseMutation @@ -228,10 +231,11 @@ end # 4. Mutation - Destroy Delete def destroy_delete_mutation class_name: "souls" file_path = "./app/graphql/mutations/#{class_name}/destroy_delete_#{class_name}.rb" + return "Mutation already exist! #{file_path}" if File.exist? file_path File.open(file_path, "w") do |f| f.write <<~EOS module Mutations module #{class_name.camelize} class DestroyDelete#{class_name.camelize} < BaseMutation @@ -256,10 +260,11 @@ puts error end def mutation class_name: "souls" singularized_class_name = class_name.singularize - + file_path = "./app/graphql/mutations/#{singularized_class_name}/create_#{singularized_class_name}.rb" + return "Mutation already exist! #{file_path}" if File.exist? file_path create_mutation_head class_name: singularized_class_name relation_params = create_mutation_params class_name: singularized_class_name create_mutation_after_params class_name: singularized_class_name, relation_params: relation_params [ create_mutation_end(class_name: singularized_class_name),