souls 2.0.3 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -28
- data/lib/souls/cli/create/index.rb +0 -62
- data/lib/souls/cli/db/create_migration.rb +0 -1
- data/lib/souls/cli/db/index.rb +0 -2
- data/lib/souls/cli/delete/application.rb +2 -18
- data/lib/souls/cli/delete/job.rb +0 -1
- data/lib/souls/cli/delete/manager.rb +0 -1
- data/lib/souls/cli/delete/migration_file.rb +0 -1
- data/lib/souls/cli/gcloud/iam/index.rb +17 -19
- data/lib/souls/cli/generate/application.rb +2 -27
- data/lib/souls/cli/generate/job.rb +0 -1
- data/lib/souls/cli/generate/manager.rb +0 -1
- data/lib/souls/cli/generate/mutation.rb +2 -2
- data/lib/souls/cli/init/index.rb +0 -9
- data/lib/souls/cli/update/index.rb +0 -7
- data/lib/souls/cli/upgrade/index.rb +0 -1
- data/lib/souls/cli.rb +2 -20
- data/lib/souls/utils/index.rb +0 -13
- data/lib/souls/version.rb +1 -1
- data/lib/souls/versions/.souls_api_version +1 -1
- data/lib/souls/versions/.souls_worker_version +1 -1
- metadata +5 -26
- data/lib/souls/cli/db/create_migration_rbs.rb +0 -25
- data/lib/souls/cli/db/model_rbs.rb +0 -22
- data/lib/souls/cli/delete/connection_rbs.rb +0 -16
- data/lib/souls/cli/delete/edge_rbs.rb +0 -15
- data/lib/souls/cli/delete/job_rbs.rb +0 -22
- data/lib/souls/cli/delete/manager_rbs.rb +0 -17
- data/lib/souls/cli/delete/mutation_rbs.rb +0 -15
- data/lib/souls/cli/delete/query_rbs.rb +0 -16
- data/lib/souls/cli/delete/resolver_rbs.rb +0 -16
- data/lib/souls/cli/delete/type_rbs.rb +0 -16
- data/lib/souls/cli/generate/connection_rbs.rb +0 -25
- data/lib/souls/cli/generate/edge_rbs.rb +0 -28
- data/lib/souls/cli/generate/job_rbs.rb +0 -40
- data/lib/souls/cli/generate/manager_rbs.rb +0 -32
- data/lib/souls/cli/generate/mutation_rbs.rb +0 -241
- data/lib/souls/cli/generate/query_rbs.rb +0 -38
- data/lib/souls/cli/generate/resolver_rbs.rb +0 -42
- data/lib/souls/cli/generate/type_rbs.rb +0 -56
- data/lib/souls/cli/update/mutation_rbs.rb +0 -126
- data/lib/souls/cli/update/type_rbs.rb +0 -44
- data/lib/souls/cli/upgrade/submodule.rb +0 -8
@@ -1,25 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class DB < Thor
|
3
|
-
desc "create_migration_rbs [CLASS_NAME]", "Generate ActiveRecord Migration's RBS Template"
|
4
|
-
def create_migration_rbs(class_name)
|
5
|
-
file_path = ""
|
6
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
7
|
-
file_dir = "./sig/api/db/migrate"
|
8
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
9
|
-
pluralized_class_name = class_name.underscore.pluralize
|
10
|
-
file_path = "#{file_dir}/create_#{pluralized_class_name}.rbs"
|
11
|
-
File.open(file_path, "w") do |f|
|
12
|
-
f.write(<<~TEXT)
|
13
|
-
class Create#{pluralized_class_name.camelize}
|
14
|
-
def change: () -> untyped
|
15
|
-
def create_table: (:#{pluralized_class_name}) { (untyped) -> untyped } -> untyped
|
16
|
-
def add_index: (:#{pluralized_class_name}, *untyped) -> untyped
|
17
|
-
end
|
18
|
-
TEXT
|
19
|
-
end
|
20
|
-
SOULs::Painter.create_file(file_path.to_s)
|
21
|
-
end
|
22
|
-
file_path
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class DB < Thor
|
3
|
-
desc "model_rbs [CLASS_NAME]", "Generate GraphQL Model RBS from schema.rb"
|
4
|
-
def model_rbs(class_name)
|
5
|
-
file_path = ""
|
6
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
7
|
-
file_dir = "./sig/api/app/models/"
|
8
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
9
|
-
singularized_class_name = class_name.underscore.singularize
|
10
|
-
file_path = "#{file_dir}#{singularized_class_name}.rbs"
|
11
|
-
File.open(file_path, "w") do |f|
|
12
|
-
f.write(<<~TEXT)
|
13
|
-
class #{singularized_class_name.camelize} < ActiveRecord::Base
|
14
|
-
end
|
15
|
-
TEXT
|
16
|
-
end
|
17
|
-
SOULs::Painter.create_file(file_path.to_s)
|
18
|
-
end
|
19
|
-
file_path
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Delete < Thor
|
3
|
-
desc "connection_rbs [CLASS_NAME]", "Delete GraphQL Connection RBS"
|
4
|
-
def connection_rbs(class_name)
|
5
|
-
file_path = ""
|
6
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
7
|
-
singularized_class_name = class_name.underscore.singularize
|
8
|
-
file_dir = "./sig/api/app/graphql/types/connections/"
|
9
|
-
file_path = "#{file_dir}#{singularized_class_name}_connection.rbs"
|
10
|
-
FileUtils.rm_f(file_path)
|
11
|
-
SOULs::Painter.delete_file(file_path.to_s)
|
12
|
-
end
|
13
|
-
file_path
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Delete < Thor
|
3
|
-
desc "edge_rbs [CLASS_NAME]", "Delete GraphQL Edge RBS"
|
4
|
-
def edge_rbs(class_name)
|
5
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
6
|
-
file_dir = "./sig/api/app/graphql/types/edges/"
|
7
|
-
singularized_class_name = class_name.underscore.singularize
|
8
|
-
file_path = "#{file_dir}#{singularized_class_name}_edge.rbs"
|
9
|
-
FileUtils.rm_f(file_path)
|
10
|
-
SOULs::Painter.delete_file(file_path)
|
11
|
-
file_path
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Delete < Thor
|
3
|
-
desc "job_rbs [CLASS_NAME]", "Delete SOULs Job Mutation RBS Template"
|
4
|
-
def job_rbs(class_name)
|
5
|
-
file_path = ""
|
6
|
-
worker_name = FileUtils.pwd.split("/").last
|
7
|
-
if worker_name == "api" || FileUtils.pwd.split("/")[-2] != "apps"
|
8
|
-
raise(SOULs::CLIException, "This task must be run from within a worker directory")
|
9
|
-
end
|
10
|
-
|
11
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
12
|
-
singularized_class_name = class_name.underscore.singularize
|
13
|
-
file_dir = "./sig/#{worker_name}/app/graphql/queries/"
|
14
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
15
|
-
file_path = "#{file_dir}#{singularized_class_name}.rbs"
|
16
|
-
FileUtils.rm_f(file_path)
|
17
|
-
SOULs::Painter.delete_file(file_path.to_s)
|
18
|
-
end
|
19
|
-
file_path
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Delete < Thor
|
3
|
-
desc "manager_rbs [CLASS_NAME]", "Delete SOULs Manager RBS Template"
|
4
|
-
method_option :mutation, aliases: "--mutation", required: true, desc: "Mutation File Name"
|
5
|
-
def manager_rbs(class_name)
|
6
|
-
file_path = ""
|
7
|
-
singularized_class_name = class_name.underscore.singularize
|
8
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
9
|
-
file_dir = "./sig/api/app/graphql/mutations/managers/#{singularized_class_name}_manager"
|
10
|
-
file_path = "#{file_dir}/#{options[:mutation]}.rbs"
|
11
|
-
FileUtils.rm_f(file_path)
|
12
|
-
SOULs::Painter.delete_file(file_path.to_s)
|
13
|
-
end
|
14
|
-
file_path
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Delete < Thor
|
3
|
-
desc "mutation_rbs [CLASS_NAME]", "Delete GraphQL Mutation RBS"
|
4
|
-
def mutation_rbs(class_name)
|
5
|
-
singularized_class_name = class_name.underscore.singularize
|
6
|
-
file_path = ""
|
7
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
8
|
-
file_dir = "./sig/api/app/graphql/mutations/base/#{singularized_class_name}"
|
9
|
-
FileUtils.rm_rf(file_dir)
|
10
|
-
end
|
11
|
-
SOULs::Painter.delete_file(file_path.to_s)
|
12
|
-
file_path
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Delete < Thor
|
3
|
-
desc "query_rbs [CLASS_NAME]", "Delete GraphQL Query RBS"
|
4
|
-
def query_rbs(class_name)
|
5
|
-
file_path = ""
|
6
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
7
|
-
file_dir = "./sig/api/app/graphql/queries/"
|
8
|
-
singularized_class_name = class_name.underscore.singularize
|
9
|
-
file_path = "#{file_dir}#{singularized_class_name}*.rbs"
|
10
|
-
FileUtils.rm_f(file_path)
|
11
|
-
SOULs::Painter.delete_file(file_path.to_s)
|
12
|
-
file_path
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Delete < Thor
|
3
|
-
desc "resolver_rbs [CLASS_NAME]", "Delete GraphQL Resolver RBS"
|
4
|
-
def resolver_rbs(class_name)
|
5
|
-
singularized_class_name = class_name.underscore.singularize
|
6
|
-
file_path = ""
|
7
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
8
|
-
file_dir = "./sig/api/app/graphql/resolvers"
|
9
|
-
file_path = "#{file_dir}/#{singularized_class_name}_search.rbs"
|
10
|
-
FileUtils.rm_f(file_path)
|
11
|
-
end
|
12
|
-
SOULs::Painter.delete_file(file_path.to_s)
|
13
|
-
file_path
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Delete < Thor
|
3
|
-
desc "type_rbs [CLASS_NAME]", "Delete GraphQL Type RBS"
|
4
|
-
def type_rbs(class_name)
|
5
|
-
singularized_class_name = class_name.underscore.singularize
|
6
|
-
file_path = ""
|
7
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
8
|
-
file_dir = "./sig/api/app/graphql/types"
|
9
|
-
file_path = "#{file_dir}/#{singularized_class_name}_type.rbs"
|
10
|
-
FileUtils.rm_f(file_path)
|
11
|
-
end
|
12
|
-
SOULs::Painter.delete_file(file_path.to_s)
|
13
|
-
file_path
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Generate < Thor
|
3
|
-
desc "connection_rbs [CLASS_NAME]", "Generate GraphQL Connection RBS from schema.rb"
|
4
|
-
def connection_rbs(class_name)
|
5
|
-
file_path = ""
|
6
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
7
|
-
file_dir = "./sig/api/app/graphql/types/connections/"
|
8
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
9
|
-
singularized_class_name = class_name.underscore.singularize
|
10
|
-
file_path = "#{file_dir}#{singularized_class_name}_connection.rbs"
|
11
|
-
File.open(file_path, "w") do |f|
|
12
|
-
f.write(<<~TEXT)
|
13
|
-
module Types
|
14
|
-
class #{singularized_class_name.camelize}Connection < Types::BaseConnection
|
15
|
-
def self.edge_type: (*untyped) -> untyped
|
16
|
-
end
|
17
|
-
end
|
18
|
-
TEXT
|
19
|
-
end
|
20
|
-
SOULs::Painter.create_file(file_path.to_s)
|
21
|
-
end
|
22
|
-
file_path
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Generate < Thor
|
3
|
-
desc "edge_rbs [CLASS_NAME]", "Generate GraphQL Edge RBS from schema.rb"
|
4
|
-
def edge_rbs(class_name)
|
5
|
-
file_path = ""
|
6
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
7
|
-
file_dir = "./sig/api/app/graphql/types/edges/"
|
8
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
9
|
-
singularized_class_name = class_name.underscore.singularize
|
10
|
-
file_path = "#{file_dir}#{singularized_class_name}_edge.rbs"
|
11
|
-
File.open(file_path, "w") do |f|
|
12
|
-
f.write(<<~TEXT)
|
13
|
-
module Types
|
14
|
-
class #{singularized_class_name.camelize}Edge < Types::BaseEdge
|
15
|
-
def self.edge_type: (*untyped) -> untyped
|
16
|
-
def self.node_type: (*untyped) -> untyped
|
17
|
-
def self.global_id_field: (*untyped) -> untyped
|
18
|
-
def self.connection_type: ()-> untyped
|
19
|
-
end
|
20
|
-
end
|
21
|
-
TEXT
|
22
|
-
end
|
23
|
-
SOULs::Painter.create_file(file_path.to_s)
|
24
|
-
end
|
25
|
-
file_path
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Generate < Thor
|
3
|
-
desc "job_rbs [CLASS_NAME]", "Generate SOULs Job Mutation RBS Template"
|
4
|
-
def job_rbs(class_name)
|
5
|
-
file_path = ""
|
6
|
-
worker_name = FileUtils.pwd.split("/").last
|
7
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
8
|
-
singularized_class_name = class_name.underscore.singularize
|
9
|
-
file_dir = "./sig/#{worker_name}/app/graphql/queries/"
|
10
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
11
|
-
file_path = "#{file_dir}#{singularized_class_name}.rbs"
|
12
|
-
sig_type_path = "./sig/#{worker_name}/app/graphql/types"
|
13
|
-
FileUtils.mkdir_p(sig_type_path) unless Dir.exist?(sig_type_path)
|
14
|
-
type_file_path = "#{sig_type_path}/#{singularized_class_name}_type.rbs"
|
15
|
-
File.open(file_path, "w") do |f|
|
16
|
-
f.write(<<~TEXT)
|
17
|
-
module Queries
|
18
|
-
class #{singularized_class_name.camelize} < BaseQuery
|
19
|
-
def self.description: (String) -> untyped
|
20
|
-
def self.field: (:response, String, null: false) -> untyped
|
21
|
-
def self.type: (untyped, null: false) -> untyped
|
22
|
-
end
|
23
|
-
end
|
24
|
-
TEXT
|
25
|
-
end
|
26
|
-
File.open(type_file_path, "w") do |f|
|
27
|
-
f.write(<<~TEXT)
|
28
|
-
module Types
|
29
|
-
class #{singularized_class_name.camelize}Type < SOULs::Types::BaseObject
|
30
|
-
def self.field: (:response, String, null: true) -> untyped
|
31
|
-
end
|
32
|
-
end
|
33
|
-
TEXT
|
34
|
-
end
|
35
|
-
SOULs::Painter.create_file(file_path.to_s)
|
36
|
-
end
|
37
|
-
file_path
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Generate < Thor
|
3
|
-
desc "manager_rbs [CLASS_NAME]", "Generate SOULs Manager RBS Template"
|
4
|
-
method_option :mutation, aliases: "--mutation", required: true, desc: "Mutation File Name"
|
5
|
-
def manager_rbs(class_name)
|
6
|
-
file_path = ""
|
7
|
-
singularized_class_name = class_name.underscore.singularize
|
8
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
9
|
-
file_dir = "./sig/api/app/graphql/mutations/managers/#{singularized_class_name}_manager"
|
10
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
11
|
-
file_path = "#{file_dir}/#{options[:mutation]}.rbs"
|
12
|
-
File.open(file_path, "w") do |f|
|
13
|
-
f.write(<<~TEXT)
|
14
|
-
module Mutations
|
15
|
-
module Managers
|
16
|
-
module #{singularized_class_name.camelize}Manager
|
17
|
-
class #{options[:mutation].singularize.camelize} < BaseMutation
|
18
|
-
def self.description: (String)-> untyped
|
19
|
-
def self.argument: (untyped, untyped, untyped)-> untyped
|
20
|
-
def self.field: (untyped, untyped, untyped)-> untyped
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
TEXT
|
26
|
-
SOULs::Painter.create_file(file_path.to_s)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
file_path
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,241 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Generate < Thor
|
3
|
-
desc "mutation_rbs [CLASS_NAME]", "Generate GraphQL Mutation RBS from schema.rb"
|
4
|
-
def mutation_rbs(class_name)
|
5
|
-
singularized_class_name = class_name.underscore.singularize
|
6
|
-
create_rbs_mutation(class_name: singularized_class_name)
|
7
|
-
update_rbs_mutation(class_name: singularized_class_name)
|
8
|
-
delete_rbs_mutation(class_name: singularized_class_name)
|
9
|
-
destroy_delete_rbs_mutation(class_name: singularized_class_name)
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def create_rbs_mutation(class_name: "user")
|
15
|
-
file_path = ""
|
16
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
17
|
-
file_dir = "./sig/api/app/graphql/mutations/base/#{class_name}"
|
18
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
19
|
-
file_path = "#{file_dir}/create_#{class_name}.rbs"
|
20
|
-
raise(Thor::Error, "Mutation RBS already exist! #{file_path}") if File.exist?(file_path)
|
21
|
-
|
22
|
-
params = SOULs.get_relation_params(class_name:, col: "mutation")
|
23
|
-
File.open(file_path, "w") do |f|
|
24
|
-
f.write(<<~TEXT)
|
25
|
-
class Boolean
|
26
|
-
end
|
27
|
-
module Mutations
|
28
|
-
module Base
|
29
|
-
module #{class_name.camelize}
|
30
|
-
class Create#{class_name.camelize} < BaseMutation
|
31
|
-
String: String
|
32
|
-
Boolean: Boolean
|
33
|
-
Integer: Integer
|
34
|
-
def resolve: ({
|
35
|
-
TEXT
|
36
|
-
end
|
37
|
-
File.open(file_path, "a") do |f|
|
38
|
-
params[:params].each_with_index do |param, i|
|
39
|
-
type = SOULs.rbs_type_check(param[:type])
|
40
|
-
type = "[#{type}]" if param[:array]
|
41
|
-
if i == params[:params].size - 1
|
42
|
-
f.write(" #{param[:column_name]}: #{type}?\n")
|
43
|
-
elsif param[:column_name].match?(/$*_id\z/)
|
44
|
-
f.write(" #{param[:column_name]}: String?,\n")
|
45
|
-
else
|
46
|
-
f.write(" #{param[:column_name]}: #{type}?,\n")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
# rubocop:disable Layout/LineLength
|
51
|
-
File.open(file_path, "a") do |f|
|
52
|
-
f.write(" }) -> ({ :#{class_name}_edge => { :node => String } } | ::GraphQL::ExecutionError )\n\n")
|
53
|
-
end
|
54
|
-
# rubocop:enable Layout/LineLength
|
55
|
-
|
56
|
-
File.open(file_path, "a") do |f|
|
57
|
-
params[:params].each_with_index do |param, i|
|
58
|
-
type = SOULs.type_check(param[:type])
|
59
|
-
rbs_type = SOULs.rbs_type_check(param[:type])
|
60
|
-
type = "[#{type}]" if param[:array]
|
61
|
-
if i.zero?
|
62
|
-
if param[:column_name].match?(/$*_id\z/)
|
63
|
-
f.write(
|
64
|
-
" def self.argument: (:#{param[:column_name]}, String, " \
|
65
|
-
"required: false ) -> #{rbs_type}\n"
|
66
|
-
)
|
67
|
-
else
|
68
|
-
f.write(
|
69
|
-
" def self.argument: (:#{param[:column_name]}, #{type}, " \
|
70
|
-
"required: false ) -> #{rbs_type}\n"
|
71
|
-
)
|
72
|
-
end
|
73
|
-
elsif param[:column_name].match?(/$*_id\z/)
|
74
|
-
f.write(" | (:#{param[:column_name]}, String, required: false ) -> String\n")
|
75
|
-
else
|
76
|
-
f.write(
|
77
|
-
" | (:#{param[:column_name]}, #{type}, " \
|
78
|
-
"required: false ) -> #{rbs_type}\n"
|
79
|
-
)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
File.open(file_path, "a") do |f|
|
85
|
-
f.write(<<~TEXT)
|
86
|
-
|
87
|
-
def self.field: (*untyped) -> String
|
88
|
-
attr_accessor context: {user:{
|
89
|
-
id: Integer,
|
90
|
-
username: String,
|
91
|
-
email: String
|
92
|
-
}}
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
TEXT
|
98
|
-
end
|
99
|
-
end
|
100
|
-
SOULs::Painter.create_file(file_path.to_s)
|
101
|
-
file_path
|
102
|
-
end
|
103
|
-
|
104
|
-
def update_rbs_mutation(class_name: "user")
|
105
|
-
file_path = ""
|
106
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
107
|
-
file_dir = "./sig/api/app/graphql/mutations/base/#{class_name}"
|
108
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
109
|
-
file_path = "#{file_dir}/update_#{class_name}.rbs"
|
110
|
-
params = SOULs.get_relation_params(class_name:, col: "mutation")
|
111
|
-
params[:params] << { column_name: "id", type: "string", array: false }
|
112
|
-
File.open(file_path, "w") do |f|
|
113
|
-
f.write(<<~TEXT)
|
114
|
-
module Mutations
|
115
|
-
module Base
|
116
|
-
module #{class_name.camelize}
|
117
|
-
class Update#{class_name.camelize} < BaseMutation
|
118
|
-
String: String
|
119
|
-
Boolean: Boolean
|
120
|
-
Integer: Integer
|
121
|
-
def resolve: ({
|
122
|
-
id: String,
|
123
|
-
TEXT
|
124
|
-
end
|
125
|
-
File.open(file_path, "a") do |f|
|
126
|
-
cols = params[:params].reject { |n| n[:column_name] == "user_id" }
|
127
|
-
cols.each_with_index do |param, i|
|
128
|
-
type = SOULs.rbs_type_check(param[:type])
|
129
|
-
type = "[#{type}]" if param[:array]
|
130
|
-
type = "String" if param[:column_name].match?(/$*_id\z/)
|
131
|
-
|
132
|
-
if i == params[:params].size - 1
|
133
|
-
f.write(" #{param[:column_name]}: #{type}?\n")
|
134
|
-
else
|
135
|
-
f.write(" #{param[:column_name]}: #{type}?,\n")
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
# rubocop:disable Layout/LineLength
|
140
|
-
File.open(file_path, "a") do |f|
|
141
|
-
f.write(" }) -> ({ :#{class_name}_edge => { :node => String } } | ::GraphQL::ExecutionError )\n\n")
|
142
|
-
end
|
143
|
-
# rubocop:enable Layout/LineLength
|
144
|
-
|
145
|
-
File.open(file_path, "a") do |f|
|
146
|
-
cols = params[:params].reject { |n| n[:column_name] == "user_id" }
|
147
|
-
cols.each_with_index do |param, i|
|
148
|
-
type = SOULs.type_check(param[:type])
|
149
|
-
rbs_type = SOULs.rbs_type_check(param[:type])
|
150
|
-
type = "[#{type}]" if param[:array]
|
151
|
-
type = "String" if param[:column_name].match?(/$*_id\z/)
|
152
|
-
rbs_type = "String" if param[:column_name].match?(/$*_id\z/)
|
153
|
-
|
154
|
-
required = param[:column_name] == "id" ? "required: true" : "required: false"
|
155
|
-
if i.zero?
|
156
|
-
f.write(" def self.argument: (:#{param[:column_name]}, #{type}, #{required} ) -> #{rbs_type}\n")
|
157
|
-
else
|
158
|
-
f.write(" | (:#{param[:column_name]}, #{type}, #{required} ) -> #{rbs_type}\n")
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
File.open(file_path, "a") do |f|
|
164
|
-
f.write(<<~TEXT)
|
165
|
-
|
166
|
-
def self.field: (*untyped) -> String
|
167
|
-
attr_accessor context: {user:{
|
168
|
-
id: Integer,
|
169
|
-
username: String,
|
170
|
-
email: String
|
171
|
-
}}
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
TEXT
|
177
|
-
end
|
178
|
-
end
|
179
|
-
SOULs::Painter.create_file(file_path.to_s)
|
180
|
-
file_path
|
181
|
-
end
|
182
|
-
|
183
|
-
def delete_rbs_mutation(class_name: "user")
|
184
|
-
file_path = ""
|
185
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
186
|
-
file_dir = "./sig/api/app/graphql/mutations/base/#{class_name}"
|
187
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
188
|
-
file_path = "#{file_dir}/delete_#{class_name}.rbs"
|
189
|
-
File.open(file_path, "w") do |f|
|
190
|
-
f.write(<<~TEXT)
|
191
|
-
module Mutations
|
192
|
-
module Base
|
193
|
-
module #{class_name.camelize}
|
194
|
-
class Delete#{class_name.camelize}
|
195
|
-
def resolve: ({
|
196
|
-
id: String
|
197
|
-
}) -> ( Hash[Symbol, untyped] | ::GraphQL::ExecutionError )
|
198
|
-
#{' '}
|
199
|
-
def self.argument: (*untyped) -> String
|
200
|
-
def self.field: (*untyped) -> String
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
TEXT
|
206
|
-
end
|
207
|
-
SOULs::Painter.create_file(file_path.to_s)
|
208
|
-
end
|
209
|
-
file_path
|
210
|
-
end
|
211
|
-
|
212
|
-
def destroy_delete_rbs_mutation(class_name: "user")
|
213
|
-
file_path = ""
|
214
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
215
|
-
file_dir = "./sig/api/app/graphql/mutations/base/#{class_name}"
|
216
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
217
|
-
file_path = "#{file_dir}/destroy_delete_#{class_name}.rbs"
|
218
|
-
File.open(file_path, "w") do |f|
|
219
|
-
f.write(<<~TEXT)
|
220
|
-
module Mutations
|
221
|
-
module Base
|
222
|
-
module #{class_name.camelize}
|
223
|
-
class DestroyDelete#{class_name.camelize}
|
224
|
-
def resolve: ({
|
225
|
-
id: String
|
226
|
-
}) -> ( Hash[Symbol, untyped] | ::GraphQL::ExecutionError )
|
227
|
-
#{' '}
|
228
|
-
def self.argument: (*untyped) -> String
|
229
|
-
def self.field: (*untyped) -> String
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end
|
234
|
-
TEXT
|
235
|
-
end
|
236
|
-
SOULs::Painter.create_file(file_path.to_s)
|
237
|
-
end
|
238
|
-
file_path
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Generate < Thor
|
3
|
-
desc "query_rbs [CLASS_NAME]", "Generate GraphQL Query RBS"
|
4
|
-
def query_rbs(class_name)
|
5
|
-
single_query_rbs(class_name)
|
6
|
-
end
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def single_query_rbs(class_name)
|
11
|
-
file_path = ""
|
12
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
13
|
-
file_dir = "./sig/api/app/graphql/queries/"
|
14
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
15
|
-
singularized_class_name = class_name.underscore.singularize
|
16
|
-
file_path = "#{file_dir}#{singularized_class_name}.rbs"
|
17
|
-
File.open(file_path, "w") do |f|
|
18
|
-
f.write(<<~TEXT)
|
19
|
-
module Queries
|
20
|
-
class BaseQuery
|
21
|
-
end
|
22
|
-
class #{singularized_class_name.camelize} < Queries::BaseQuery
|
23
|
-
def resolve: ({
|
24
|
-
id: String?
|
25
|
-
}) -> ( Hash[Symbol, ( String | Integer | bool )] | ::GraphQL::ExecutionError )
|
26
|
-
|
27
|
-
def self.argument: (*untyped) -> String
|
28
|
-
def self.type: (*untyped) -> String
|
29
|
-
end
|
30
|
-
end
|
31
|
-
TEXT
|
32
|
-
end
|
33
|
-
SOULs::Painter.create_file(file_path.to_s)
|
34
|
-
end
|
35
|
-
file_path
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Generate < Thor
|
3
|
-
desc "resolver_rbs [CLASS_NAME]", "Generate GraphQL Resolver RBS from schema.rb"
|
4
|
-
def resolver_rbs(class_name)
|
5
|
-
singularized_class_name = class_name.underscore.singularize
|
6
|
-
file_path = ""
|
7
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
8
|
-
file_dir = "./sig/api/app/graphql/resolvers"
|
9
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
10
|
-
file_path = "#{file_dir}/#{singularized_class_name}_search.rbs"
|
11
|
-
raise(Thor::Error, "Mutation RBS already exist! #{file_path}") if File.exist?(file_path)
|
12
|
-
|
13
|
-
File.open(file_path, "w") do |f|
|
14
|
-
f.write(<<~TEXT)
|
15
|
-
module Resolvers
|
16
|
-
class BaseResolver
|
17
|
-
end
|
18
|
-
class #{singularized_class_name.camelize}Search < BaseResolver
|
19
|
-
include SearchObject
|
20
|
-
def self.scope: () ?{ () -> nil } -> [Hash[Symbol, untyped]]
|
21
|
-
def self.type: (*untyped) -> String
|
22
|
-
def self.option: (:filter, type: untyped, with: :apply_filter) -> String
|
23
|
-
def self.description: (String) -> String
|
24
|
-
def self.types: (*untyped) -> String
|
25
|
-
def decode_global_key: (String value) -> Integer
|
26
|
-
def apply_filter: (untyped scope, untyped value) -> untyped
|
27
|
-
|
28
|
-
class #{singularized_class_name.camelize}Filter
|
29
|
-
String: String
|
30
|
-
Boolean: Boolean
|
31
|
-
Integer: Integer
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
TEXT
|
36
|
-
end
|
37
|
-
end
|
38
|
-
SOULs::Painter.create_file(file_path.to_s)
|
39
|
-
file_path
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|