souls 0.63.6 → 0.64.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73945900410549a363adfa2f96535e981a7908e99b8011c099787112ee2c952d
4
- data.tar.gz: 4985467cccfbb4b8640981e7af4bf9289581eeb0c7a2a46cc5834ef2d2d6c1fc
3
+ metadata.gz: a3a33999e189283758881dbe8f9d0a7222580ca0b359363d845142aecc6faf63
4
+ data.tar.gz: addf19b1163e5ae31937b0fe49ce464ed4de286d1edc013385a968dd721f858d
5
5
  SHA512:
6
- metadata.gz: d9669e9c807324a46e8b46ab81883cbebe74a5f500bf7d1c34c0ea02407a5c425dcc920f656ea42e6085a82af3f2f526e1f0336a9dc606e236eaf468fc74c482
7
- data.tar.gz: 59be6c42d9b8576f73afabb5eee58b4ca0658cfc721d4e6ae22352b3206ef39da177ebd34339c158ce016bbc8fd02424a97a7c36235b42af1282ef5764b56b0c
6
+ metadata.gz: f19ae2ed49b96c8ac03e5944c79ac9f0cd8da0a4e7875660c83236c0cc645c16f064c4f97fa53d1b7c9ee3ae61ad9648c1cd3a4f84c038034ed57743cca7edc2
7
+ data.tar.gz: e95ee79d899afb8a255018c6d0da216e400f0689690cb2d1cc4a83f30c644ee7f2d7d35597f17a0ab07db1e887b1e0b29e7d786c51ab6d620351384f07b65d8d
@@ -3,17 +3,18 @@ module Souls
3
3
  desc "mutation [CLASS_NAME]", "Generate GraphQL Mutation from schema.rb"
4
4
  def mutation(class_name)
5
5
  singularized_class_name = class_name.singularize
6
- file_dir = "./app/graphql/mutations/base"
7
- FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
8
- file_path = "./app/graphql/mutations/base/#{singularized_class_name}/create_#{singularized_class_name}.rb"
9
- return "Mutation already exist! #{file_path}" if File.exist?(file_path)
10
6
 
11
- create_mutation(class_name: singularized_class_name)
12
- update_mutation(class_name: singularized_class_name)
13
- delete_mutation(class_name: singularized_class_name)
14
- destroy_delete_mutation(class_name: singularized_class_name)
15
- puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
16
- file_path
7
+ Dir.chdir(Souls.get_api_path.to_s) do
8
+ file_dir = "./app/graphql/mutations/base"
9
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
10
+ file_path = "./app/graphql/mutations/base/#{singularized_class_name}/create_#{singularized_class_name}.rb"
11
+ return "Mutation already exist! #{file_path}" if File.exist?(file_path)
12
+
13
+ create_mutation(class_name: singularized_class_name)
14
+ update_mutation(class_name: singularized_class_name)
15
+ delete_mutation(class_name: singularized_class_name)
16
+ destroy_delete_mutation(class_name: singularized_class_name)
17
+ end
17
18
  rescue Thor::Error => e
18
19
  raise(Thor::Error, e)
19
20
  end
@@ -21,64 +22,78 @@ module Souls
21
22
  private
22
23
 
23
24
  def create_mutation(class_name: "user")
24
- file_path = ""
25
25
  singularized_class_name = class_name.singularize.underscore
26
- Dir.chdir(Souls.get_api_path.to_s) do
27
- file_dir = "./app/graphql/mutations/base/#{singularized_class_name}"
28
- FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
29
- file_path = "#{file_dir}/create_#{singularized_class_name}.rb"
30
- raise(Thor::Error, "Mutation RBS already exist! #{file_path}") if File.exist?(file_path)
31
-
32
- params = Souls.get_relation_params(class_name: singularized_class_name, col: "mutation")
33
- File.open(file_path, "w") do |f|
34
- f.write(<<~TEXT)
35
- module Mutations
36
- module Base::#{singularized_class_name.camelize}
37
- class Create#{singularized_class_name.camelize} < BaseMutation
38
- field :#{singularized_class_name}_edge, Types::#{singularized_class_name.camelize}Type.edge_type, null: false
39
- field :error, String, null: true
40
-
41
- def resolve(args)
42
- TEXT
43
- end
44
- File.open(file_path, "a") do |f|
45
- if params[:relation_params]
46
- f.write(" user_id = context[:user][:id]\n") if params[:user_exist]
47
- params[:relation_params].each_with_index do |col, _i|
48
- next if col[:column_name] == "user_id"
26
+ file_dir = "./app/graphql/mutations/base/#{singularized_class_name}"
27
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
28
+ file_path = "#{file_dir}/create_#{singularized_class_name}.rb"
29
+ raise(Thor::Error, "Mutation RBS already exist! #{file_path}") if File.exist?(file_path)
49
30
 
50
- f.write(" #{col[:column_name]} = SoulsApiSchema.from_global_id(args[:#{col[:column_name]}])\n")
51
- end
52
- relation_params =
53
- params[:relation_params].map do |n|
54
- ", #{n[:column_name]}: #{n[:column_name]}"
55
- end
56
- f.write(" new_record = { **args #{relation_params.compact.join} }\n")
57
- f.write(" data = ::#{singularized_class_name.camelize}.new(new_record)\n")
31
+ params = Souls.get_relation_params(class_name: singularized_class_name, col: "mutation")
32
+ File.open(file_path, "w") do |f|
33
+ f.write(<<~TEXT)
34
+ module Mutations
35
+ module Base::#{singularized_class_name.camelize}
36
+ class Create#{singularized_class_name.camelize} < BaseMutation
37
+ field :#{singularized_class_name}_edge, Types::#{singularized_class_name.camelize}Type.edge_type, null: false
38
+ field :error, String, null: true
39
+
40
+ TEXT
41
+ end
42
+
43
+ File.open(file_path, "a") do |f|
44
+ params[:params].each_with_index do |param, i|
45
+ type = Souls.type_check(param[:type])
46
+ type = "[#{type}]" if param[:array]
47
+ type = "String" if param[:column_name].match?(/$*_id\z/)
48
+ if i == params[:params].size - 1
49
+ f.write(" argument :#{param[:column_name]}, #{type}, required: false\n\n")
50
+ f.write(" def resolve(args)\n")
58
51
  else
59
- f.write(" data = ::#{singularized_class_name.camelize}.new(args)\n")
52
+ f.write(" argument :#{param[:column_name]}, #{type}, required: false\n")
60
53
  end
61
54
  end
62
- File.open(file_path, "a") do |new_line|
63
- new_line.write(<<~TEXT)
64
- raise(StandardError, data.errors.full_messages) unless data.save
55
+ end
56
+
57
+ File.open(file_path, "a") do |f|
58
+ if params[:relation_params]
59
+ f.write(" user_id = context[:user][:id]\n") if params[:user_exist]
60
+ params[:relation_params].each_with_index do |col, _i|
61
+ next if col[:column_name] == "user_id"
65
62
 
66
- { #{singularized_class_name}_edge: { node: data } }
67
- rescue StandardError => error
68
- GraphQL::ExecutionError.new(error.message)
69
- end
63
+ f.write(" _, #{col[:column_name]} = SoulsApiSchema.from_global_id(args[:#{col[:column_name]}])\n")
64
+ end
65
+ relation_params =
66
+ params[:relation_params].map do |n|
67
+ ", #{n[:column_name]}: #{n[:column_name]}"
68
+ end
69
+ f.write(" new_record = { **args #{relation_params.compact.join} }\n")
70
+ f.write(" data = ::#{singularized_class_name.camelize}.new(new_record)\n")
71
+ else
72
+ f.write(" data = ::#{singularized_class_name.camelize}.new(args)\n")
73
+ end
74
+ end
75
+ File.open(file_path, "a") do |new_line|
76
+ new_line.write(<<~TEXT)
77
+ raise(StandardError, data.errors.full_messages) unless data.save
78
+
79
+ { #{singularized_class_name}_edge: { node: data } }
80
+ rescue StandardError => error
81
+ GraphQL::ExecutionError.new(error.message)
70
82
  end
71
83
  end
72
84
  end
73
- TEXT
74
- end
85
+ end
86
+ TEXT
75
87
  end
88
+ puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
76
89
  file_path
77
90
  end
78
91
 
79
92
  ## 2.Mutation - Update
80
93
  def update_mutation_head(class_name: "user")
81
- file_path = "./app/graphql/mutations/base/#{class_name}/update_#{class_name}.rb"
94
+ singularized_class_name = class_name.singularize.underscore
95
+ file_dir = "./app/graphql/mutations/base/#{singularized_class_name}"
96
+ file_path = "#{file_dir}/update_#{class_name}.rb"
82
97
  File.open(file_path, "w") do |new_line|
83
98
  new_line.write(<<~TEXT)
84
99
  module Mutations
@@ -170,6 +185,7 @@ module Souls
170
185
  end
171
186
  TEXT
172
187
  end
188
+ puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
173
189
  file_path
174
190
  end
175
191
 
@@ -209,6 +225,7 @@ module Souls
209
225
  end
210
226
  TEXT
211
227
  end
228
+ puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
212
229
  file_path
213
230
  end
214
231
 
@@ -238,6 +255,7 @@ module Souls
238
255
  end
239
256
  TEXT
240
257
  end
258
+ puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
241
259
  file_path
242
260
  rescue StandardError => e
243
261
  puts(e)
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.63.6".freeze
2
+ VERSION = "0.64.3".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.42.6
1
+ 0.43.3
@@ -1 +1 @@
1
- 0.42.6
1
+ 0.43.3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: souls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.63.6
4
+ version: 0.64.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-09-30 00:00:00.000000000 Z
13
+ date: 2021-10-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport