graphql-rails-generators 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9068fe37ce3d14aea970bad494696cb852365038b50782ae4decffd4f70130ac
4
- data.tar.gz: 9a07980ae9886f1015e4873d9a33b4123dac3cf7aac04bb0cc8035a406e5b45c
3
+ metadata.gz: 3b58b52d9aedd9eede25bf252549e66273bdd59f60dcfadae71c858390f6b6c2
4
+ data.tar.gz: e1ce9f70a44fb26d0943498882c31631e390518bc9d699b93b8baaf6803ec05a
5
5
  SHA512:
6
- metadata.gz: 656cb0197471b75bea857458eb6bc59dce4937caba86835fce3b09f2d45ce59210e061f10ead1d9b20784576b775cc010b3d86837ade2c2ee55cd1641d054ba2
7
- data.tar.gz: d1b073eb0fbf73b19c0ec0d3da6c3d220f17b071a87e7cf69b3b8ae7ebdb146b005c3cff148dcd8f2123845c16ccf4e5842170a6cd61ac727e06e9d39385a977
6
+ metadata.gz: 2cf3908b610b74597d747de8b10d5c7f9d45297aad9fd0fd1664379fc5a3da9a2d191737b07d742d58a376b018bf11baa1bb7c5c8cd31d0cbc6334165f410427
7
+ data.tar.gz: 5eb8fe1b19b233ae06bafde06c0cbe96699c1042b20d5b21f9066cee3e4634da62924f4fd26d3ab46436070e2d7b534296131a1803f9406f29fc2396fa13bacd
@@ -1,12 +1,21 @@
1
+ require "rails/generators/named_base"
2
+
1
3
  module Gql
2
- class MutationGenerator < Rails::Generators::Base
4
+ class MutationGenerator < Rails::Generators::NamedBase
5
+ remove_argument :name # remove name base default arg
6
+
3
7
  argument :mutation_prefix, type: :string
4
8
  argument :model_name, type: :string
5
9
  source_root File.expand_path('../templates', __FILE__)
10
+
11
+ # hack to keep NamedBase helpers working
12
+ def name
13
+ model_name
14
+ end
6
15
 
7
16
  def mutation
8
- file_name = "#{mutation_prefix}#{model_name}"
9
- template('model_mutation.rb', "app/graphql/mutations/#{file_name.underscore}.rb")
17
+ file_name = "#{mutation_prefix}_#{singular_name}"
18
+ template('model_mutation.rb', "app/graphql/mutations/#{class_path.join('/')}/#{file_name.underscore}.rb")
10
19
  end
11
20
  end
12
21
 
@@ -1,6 +1,6 @@
1
1
  module Mutations
2
2
  class <%= @mutation_prefix %><%= @model_name %> < Mutations::BaseMutation
3
- field :<%= @model_name.underscore %>, Types::<%= @model_name %>Type, null: true
3
+ field :<%= singular_name %>, Types::<%= @model_name %>Type, null: true
4
4
 
5
5
  argument :attributes, Types::Input::<%= @model_name %>Input, required: true
6
6
  argument :id, Int, required: false
@@ -9,7 +9,7 @@ module Mutations
9
9
  model = find_or_build_model(id)
10
10
  model.attributes = attributes.to_h
11
11
  if model.save
12
- {<%= @model_name.underscore %>: model}
12
+ {<%= singular_name %>: model}
13
13
  else
14
14
  {errors: model.errors.full_messages}
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module GraphqlRailsGenerators
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-rails-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Sharp
@@ -10,7 +10,7 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A simple hello world gem
13
+ description: Rails graphql generators
14
14
  email: ajsharp@gmail.com
15
15
  executables: []
16
16
  extensions: []
@@ -49,5 +49,5 @@ rubyforge_project:
49
49
  rubygems_version: 2.7.9
50
50
  signing_key:
51
51
  specification_version: 4
52
- summary: Hola!
52
+ summary: Rails graphql generators
53
53
  test_files: []