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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b58b52d9aedd9eede25bf252549e66273bdd59f60dcfadae71c858390f6b6c2
|
4
|
+
data.tar.gz: e1ce9f70a44fb26d0943498882c31631e390518bc9d699b93b8baaf6803ec05a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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::
|
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}#{
|
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 :<%=
|
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
|
-
{<%=
|
12
|
+
{<%= singular_name %>: model}
|
13
13
|
else
|
14
14
|
{errors: model.errors.full_messages}
|
15
15
|
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.
|
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:
|
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:
|
52
|
+
summary: Rails graphql generators
|
53
53
|
test_files: []
|