Skip to content

Commit cffa8d7

Browse files
authored
Merge pull request #3 from ajsharp/fix-namespaced-class-name
properly generate namespaced class names
2 parents e538694 + 15173bf commit cffa8d7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/generators/gql/mutation_generator.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class MutationGenerator < Rails::Generators::NamedBase
1212
def name
1313
model_name
1414
end
15+
16+
# Generate a namedspaced class name with the mutation prefix
17+
def prefixed_class_name
18+
(class_path + ["#{mutation_prefix}_#{file_name}"]).map!(&:camelize).join("::")
19+
end
1520

1621
def mutation
1722
file_name = "#{mutation_prefix}_#{singular_name}"

lib/generators/gql/templates/model_mutation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Mutations
2-
class <%= @mutation_prefix %><%= @model_name %> < Mutations::BaseMutation
2+
class <%= prefixed_class_name %> < Mutations::BaseMutation
33
field :<%= singular_name %>, Types::<%= @model_name %>Type, null: true
44
55
argument :attributes, Types::Input::<%= @model_name %>Input, required: true

0 commit comments

Comments
 (0)