Skip to content

Commit

Permalink
properly generate namespaced class names
Browse files Browse the repository at this point in the history
  • Loading branch information
ajsharp committed Dec 29, 2019
1 parent e538694 commit 15173bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/generators/gql/mutation_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class MutationGenerator < Rails::Generators::NamedBase
def name
model_name
end

# Generate a namedspaced class name with the mutation prefix
def prefixed_class_name
(class_path + ["#{mutation_prefix}_#{file_name}"]).map!(&:camelize).join("::")
end

def mutation
file_name = "#{mutation_prefix}_#{singular_name}"
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/gql/templates/model_mutation.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Mutations
class <%= @mutation_prefix %><%= @model_name %> < Mutations::BaseMutation
class <%= prefixed_class_name %> < Mutations::BaseMutation
field :<%= singular_name %>, Types::<%= @model_name %>Type, null: true
argument :attributes, Types::Input::<%= @model_name %>Input, required: true
Expand Down

0 comments on commit 15173bf

Please # to comment.