ibrain-core 0.4.3 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/ibrain/base_controller.rb +12 -14
- data/app/controllers/ibrain/core/graphql_controller.rb +79 -83
- data/app/graphql/ibrain/base_schema.rb +50 -52
- data/app/graphql/ibrain/extentions/default_value.rb +7 -11
- data/app/graphql/ibrain/extentions/roles.rb +15 -20
- data/app/graphql/ibrain/extentions/session_required.rb +10 -14
- data/app/graphql/ibrain/lazy/base.rb +2 -6
- data/app/graphql/ibrain/loaders/association_loader.rb +51 -55
- data/app/graphql/ibrain/mutations/base_mutation.rb +52 -56
- data/app/graphql/ibrain/policies/base_policy.rb +43 -47
- data/app/graphql/ibrain/policies/graphql_policy.rb +2 -6
- data/app/graphql/ibrain/resolvers/base_aggregate.rb +6 -10
- data/app/graphql/ibrain/resolvers/base_resolver.rb +8 -12
- data/app/graphql/ibrain/types/aggregate_type.rb +4 -8
- data/app/graphql/ibrain/types/attribute_type.rb +2 -5
- data/app/graphql/ibrain/types/base_api_connection.rb +6 -10
- data/app/graphql/ibrain/types/base_api_edge.rb +4 -8
- data/app/graphql/ibrain/types/base_api_field.rb +7 -11
- data/app/graphql/ibrain/types/base_api_object.rb +6 -10
- data/app/graphql/ibrain/types/base_argument.rb +3 -7
- data/app/graphql/ibrain/types/base_connection.rb +7 -11
- data/app/graphql/ibrain/types/base_edge.rb +3 -7
- data/app/graphql/ibrain/types/base_enum.rb +1 -5
- data/app/graphql/ibrain/types/base_field.rb +6 -10
- data/app/graphql/ibrain/types/base_input_object.rb +6 -10
- data/app/graphql/ibrain/types/base_interface.rb +5 -9
- data/app/graphql/ibrain/types/base_object.rb +12 -16
- data/app/graphql/ibrain/types/base_scalar.rb +1 -5
- data/app/graphql/ibrain/types/base_type.rb +4 -10
- data/app/graphql/ibrain/types/base_union.rb +3 -7
- data/app/graphql/ibrain/types/filter_type.rb +1 -5
- data/app/graphql/ibrain/types/node_type.rb +4 -8
- data/app/graphql/ibrain/util/field_combiner.rb +5 -9
- data/app/graphql/ibrain/util/query_combiner.rb +4 -8
- data/app/models/concerns/ibrain/soft_deletable.rb +6 -8
- data/app/models/concerns/ibrain/user_api_authentication.rb +14 -16
- data/app/models/concerns/ibrain/user_methods.rb +11 -13
- data/app/models/ibrain/ability.rb +31 -32
- data/app/models/ibrain/aggregate.rb +5 -7
- data/app/models/ibrain/application_record.rb +2 -4
- data/app/models/ibrain/legacy_user.rb +7 -13
- data/app/models/ibrain/role.rb +6 -8
- data/app/models/ibrain/role_user.rb +8 -10
- data/app/repositories/ibrain/base_repository.rb +9 -11
- data/lib/generators/ibrain/core/model_generator.rb +17 -21
- data/lib/generators/ibrain/graphql/core.rb +55 -59
- data/lib/generators/ibrain/graphql/mutation_generator.rb +58 -66
- data/lib/generators/ibrain/graphql/object_generator.rb +58 -70
- data/lib/generators/ibrain/graphql/resolver_generator.rb +17 -25
- data/lib/generators/ibrain/graphql/resolvers_generator.rb +59 -67
- data/lib/generators/ibrain/graphql/templates/aggregate.erb +5 -7
- data/lib/generators/ibrain/graphql/templates/input.erb +5 -9
- data/lib/generators/ibrain/graphql/templates/mutation.erb +24 -26
- data/lib/generators/ibrain/graphql/templates/object.erb +6 -10
- data/lib/generators/ibrain/graphql/templates/resolver.erb +9 -11
- data/lib/generators/ibrain/graphql/templates/resolvers.erb +8 -10
- data/lib/generators/ibrain/graphql/type_generator.rb +84 -88
- data/lib/generators/ibrain/install/install_generator.rb +137 -140
- data/lib/generators/ibrain/install/templates/graphql/types/mutation_type.rb.tt +13 -15
- data/lib/generators/ibrain/install/templates/graphql/types/query_type.rb.tt +11 -13
- data/lib/generators/ibrain/install/templates/rubocop.yml.tt +83 -30
- data/lib/ibrain/app_configuration.rb +34 -36
- data/lib/ibrain/core/class_constantizer.rb +30 -33
- data/lib/ibrain/core/controller_helpers/auth.rb +53 -59
- data/lib/ibrain/core/controller_helpers/current_host.rb +5 -11
- data/lib/ibrain/core/controller_helpers/response.rb +43 -49
- data/lib/ibrain/core/controller_helpers/strong_parameters.rb +9 -15
- data/lib/ibrain/core/engine.rb +5 -9
- data/lib/ibrain/core/environment.rb +5 -9
- data/lib/ibrain/core/environment_extension.rb +13 -17
- data/lib/ibrain/core/role_configuration.rb +52 -54
- data/lib/ibrain/core/validators/email.rb +15 -17
- data/lib/ibrain/core/version.rb +2 -2
- data/lib/ibrain/core/versioned_value.rb +61 -65
- data/lib/ibrain/core.rb +0 -1
- data/lib/ibrain/encryptor.rb +18 -20
- data/lib/ibrain/logger.rb +13 -15
- data/lib/ibrain/permission_sets/base.rb +22 -26
- data/lib/ibrain/permission_sets/super_user.rb +3 -7
- data/lib/ibrain/permitted_attributes.rb +18 -20
- data/lib/ibrain/preferences/configuration.rb +135 -137
- data/lib/ibrain/preferences/preferable.rb +158 -162
- data/lib/ibrain/preferences/preferable_class_methods.rb +112 -114
- data/lib/ibrain/user_class_handle.rb +22 -24
- data/lib/ibrain_core.rb +7 -1
- metadata +3 -18
- data/config/initializers/friendly_id.rb +0 -87
@@ -7,110 +7,106 @@ require 'active_support'
|
|
7
7
|
require 'active_support/core_ext/string/inflections'
|
8
8
|
require_relative 'core'
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
class TypeGeneratorBase < Rails::Generators::Base
|
13
|
-
include Core
|
10
|
+
class Ibrain::Graphql::TypeGeneratorBase < Rails::Generators::Base
|
11
|
+
include Core
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
argument :type_name,
|
14
|
+
type: :string,
|
15
|
+
banner: "TypeName",
|
16
|
+
desc: "Name of this object type (expressed as Ruby or GraphQL)"
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
18
|
+
# Take a type expression in any combination of GraphQL or Ruby styles
|
19
|
+
# and return it in a specified output style
|
20
|
+
# TODO: nullability / list with `mode: :graphql` doesn't work
|
21
|
+
# @param type_expresson [String]
|
22
|
+
# @param mode [Symbol]
|
23
|
+
# @param null [Boolean]
|
24
|
+
# @return [(String, Boolean)] The type expression, followed by `null:` value
|
25
|
+
def self.normalize_type_expression(type_expression, mode:, null: false)
|
26
|
+
if type_expression.start_with?("!")
|
27
|
+
normalize_type_expression(type_expression[1..-1], mode: mode, null: false)
|
28
|
+
elsif type_expression.end_with?("!")
|
29
|
+
normalize_type_expression(type_expression[0..-2], mode: mode, null: false)
|
30
|
+
elsif type_expression.start_with?("[") && type_expression.end_with?("]")
|
31
|
+
name, is_null = normalize_type_expression(type_expression[1..-2], mode: mode, null: null)
|
32
|
+
["[#{name}]", is_null]
|
33
|
+
elsif type_expression.end_with?("Type")
|
34
|
+
normalize_type_expression(type_expression[0..-5], mode: mode, null: null)
|
35
|
+
elsif type_expression.start_with?("Types::")
|
36
|
+
normalize_type_expression(type_expression[7..-1], mode: mode, null: null)
|
37
|
+
elsif type_expression.start_with?("types.")
|
38
|
+
normalize_type_expression(type_expression[6..-1], mode: mode, null: null)
|
39
|
+
else
|
40
|
+
case mode
|
41
|
+
when :ruby
|
42
|
+
case type_expression
|
43
|
+
when "Int"
|
44
|
+
["Integer", null]
|
45
|
+
when "Integer", "Float", "Boolean", "String", "ID"
|
46
|
+
[type_expression, null]
|
41
47
|
else
|
42
|
-
|
43
|
-
when :ruby
|
44
|
-
case type_expression
|
45
|
-
when "Int"
|
46
|
-
["Integer", null]
|
47
|
-
when "Integer", "Float", "Boolean", "String", "ID"
|
48
|
-
[type_expression, null]
|
49
|
-
else
|
50
|
-
["Types::#{type_expression.camelize}Type", null]
|
51
|
-
end
|
52
|
-
when :input
|
53
|
-
["Types::#{type_expression.camelize}Input", null]
|
54
|
-
when :graphql
|
55
|
-
[type_expression.camelize, null]
|
56
|
-
else
|
57
|
-
raise "Unexpected normalize mode: #{mode}"
|
58
|
-
end
|
48
|
+
["Types::#{type_expression.camelize}Type", null]
|
59
49
|
end
|
50
|
+
when :input
|
51
|
+
["Types::#{type_expression.camelize}Input", null]
|
52
|
+
when :graphql
|
53
|
+
[type_expression.camelize, null]
|
54
|
+
else
|
55
|
+
raise "Unexpected normalize mode: #{mode}"
|
60
56
|
end
|
57
|
+
end
|
58
|
+
end
|
61
59
|
|
62
|
-
|
60
|
+
private
|
63
61
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
62
|
+
# @return [String] The user-provided type name, normalized to Ruby code
|
63
|
+
def type_ruby_name
|
64
|
+
@type_ruby_name ||= self.class.normalize_type_expression(type_name, mode: :ruby)[0]
|
65
|
+
end
|
68
66
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
67
|
+
# @return [String] The user-provided type name, as a GraphQL name
|
68
|
+
def type_graphql_name
|
69
|
+
@type_graphql_name ||= self.class.normalize_type_expression(type_name, mode: :graphql)[0]
|
70
|
+
end
|
73
71
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
# @return [String] The user-provided type name, as a file name (without extension)
|
73
|
+
def type_file_name
|
74
|
+
@type_file_name ||= "#{type_graphql_name}Type".underscore
|
75
|
+
end
|
78
76
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
77
|
+
# @return [String] The user-provided type name, as a file name (without extension)
|
78
|
+
def input_file_name
|
79
|
+
@input_file_name ||= "#{type_graphql_name}Input".underscore
|
80
|
+
end
|
83
81
|
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
def input_ruby_name
|
83
|
+
@input_ruby_name ||= self.class.normalize_type_expression(type_name, mode: :input)[0]
|
84
|
+
end
|
87
85
|
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
# @return [Array<NormalizedField>] User-provided fields, in `(name, Ruby type name)` pairs
|
87
|
+
def normalized_fields
|
88
|
+
skip_fields = ["created_at:!Datetime", "updated_at:!Datetime"]
|
91
89
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
90
|
+
@normalized_fields ||= fields.reject { |f| skip_fields.include?(f) }.map { |f|
|
91
|
+
name, raw_type = f.split(":", 2)
|
92
|
+
type_expr, null = self.class.normalize_type_expression(raw_type, mode: :ruby)
|
93
|
+
NormalizedField.new(name, type_expr, null)
|
94
|
+
}
|
95
|
+
end
|
98
96
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
97
|
+
class NormalizedField
|
98
|
+
def initialize(name, type_expr, null)
|
99
|
+
@name = name
|
100
|
+
@type_expr = type_expr
|
101
|
+
@null = null
|
102
|
+
end
|
105
103
|
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
def to_ruby
|
105
|
+
"field :#{@name}, #{@type_expr}, null: #{@null}"
|
106
|
+
end
|
109
107
|
|
110
|
-
|
111
|
-
|
112
|
-
end
|
113
|
-
end
|
108
|
+
def to_argument
|
109
|
+
"argument :#{@name}, #{@type_expr}, required: #{@null}"
|
114
110
|
end
|
115
111
|
end
|
116
112
|
end
|
@@ -3,178 +3,175 @@
|
|
3
3
|
require 'rails/generators'
|
4
4
|
require 'ibrain/logger'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
ROBOTS
|
31
|
-
end
|
6
|
+
class Ibrain::InstallGenerator < Rails::Generators::Base
|
7
|
+
CORE_MOUNT_ROUTE = "mount Ibrain::Core::Engine"
|
8
|
+
source_root File.expand_path('templates', __dir__)
|
9
|
+
|
10
|
+
class_option :user_class, type: :string
|
11
|
+
class_option :with_authentication, type: :boolean, default: true
|
12
|
+
class_option :with_rubocop, type: :boolean, default: true
|
13
|
+
class_option :with_graphql, type: :boolean, default: false
|
14
|
+
class_option :with_annotation, type: :boolean, default: true
|
15
|
+
class_option :with_sendgrid, type: :boolean, default: false
|
16
|
+
class_option :enforce_available_locales, type: :boolean, default: nil
|
17
|
+
class_option :with_ridgepole, type: :boolean, default: true
|
18
|
+
|
19
|
+
def additional_tweaks
|
20
|
+
return unless File.exist? 'public/robots.txt'
|
21
|
+
|
22
|
+
append_file "public/robots.txt", <<-ROBOTS.strip_heredoc
|
23
|
+
User-agent: *
|
24
|
+
Disallow: /user
|
25
|
+
Disallow: /account
|
26
|
+
Disallow: /api
|
27
|
+
Disallow: /password
|
28
|
+
ROBOTS
|
29
|
+
end
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
def create_overrides_directory
|
32
|
+
empty_directory "app/overrides"
|
33
|
+
end
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
35
|
+
def configure_application
|
36
|
+
if !options[:enforce_available_locales].nil?
|
37
|
+
application <<-RUBY
|
38
|
+
I18n.enforce_available_locales = #{options[:enforce_available_locales]}
|
39
|
+
RUBY
|
43
40
|
end
|
41
|
+
end
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
def plugin_install_preparation
|
44
|
+
@plugins_to_be_installed = []
|
45
|
+
@plugin_generators_to_run = []
|
46
|
+
end
|
49
47
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
def install_auth_plugin
|
49
|
+
if options[:with_authentication] && (options[:auto_accept] || !no?("
|
50
|
+
Ibrain has a default authentication extension that uses Devise.
|
51
|
+
You can find more info at https://github.com/john-techfox/ibrain-auth.git.
|
54
52
|
|
55
|
-
|
53
|
+
Would you like to install it? (Y/n)"))
|
56
54
|
|
57
|
-
|
58
|
-
|
59
|
-
end
|
55
|
+
@plugins_to_be_installed << 'ibrain-auth' unless system('gem list | grep ibrain-auth')
|
56
|
+
@plugin_generators_to_run << "ibrain:auth:install --with-ridgpole=#{options[:with_ridgepole]}"
|
60
57
|
end
|
58
|
+
end
|
61
59
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
def run_bundle_install_if_needed_by_plugins
|
61
|
+
@plugins_to_be_installed.each do |plugin_name|
|
62
|
+
gem plugin_name
|
63
|
+
end
|
66
64
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
65
|
+
if options[:with_rubocop]
|
66
|
+
append_gem('rubocop', '1.23.0', 'development')
|
67
|
+
append_gem('rubocop-performance', '1.12.0', 'development')
|
68
|
+
append_gem('rubocop-rails', '2.12.4', 'development')
|
69
|
+
append_gem('rubocop-graphql', '0.11.2', 'development')
|
70
|
+
end
|
73
71
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
72
|
+
if options[:with_graphql]
|
73
|
+
append_gem('graphql', '1.12.6')
|
74
|
+
append_gem('graphql-batch', '0.4.3')
|
75
|
+
append_gem('graphql-guard', '2.0.0')
|
76
|
+
append_gem('graphql-rails-generators', '1.1.2', 'development')
|
77
|
+
append_gem('graphiql-rails', '1.8.0', 'development')
|
78
|
+
append_gem('apollo_upload_server', '2.1')
|
79
|
+
end
|
82
80
|
|
83
|
-
|
84
|
-
|
81
|
+
append_gem('annotate', '3.1.1', 'development') if options[:with_annotation]
|
82
|
+
append_gem('sendgrid-ruby', '6.6.0') if options[:with_sendgrid]
|
85
83
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
84
|
+
if options[:with_ridgepole]
|
85
|
+
append_gem('ridgepole', '1.0.0', 'development')
|
86
|
+
else
|
87
|
+
remove_gem('ridgepole')
|
88
|
+
end
|
91
89
|
|
92
|
-
|
93
|
-
|
90
|
+
bundle_cleanly{ run "bundle install" } if @plugins_to_be_installed.any?
|
91
|
+
run "spring stop" if defined?(Spring)
|
94
92
|
|
95
|
-
|
96
|
-
|
97
|
-
end
|
93
|
+
@plugin_generators_to_run.each do |plugin_generator_name|
|
94
|
+
generate plugin_generator_name.to_s
|
98
95
|
end
|
96
|
+
end
|
99
97
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
end
|
98
|
+
def install_routes
|
99
|
+
routes_file_path = File.join('config', 'routes.rb')
|
100
|
+
unless File.read(routes_file_path).include? CORE_MOUNT_ROUTE
|
101
|
+
insert_into_file routes_file_path, after: "Rails.application.routes.draw do\n" do
|
102
|
+
<<-RUBY
|
103
|
+
# This line mounts Ibrain's routes at the root of your application.
|
104
|
+
# This means, any requests to URLs such as /graphql, will go to Ibrain::GraphqlController,
|
105
|
+
# any requests to URLS such as /auth, will go to Ibrain::AuthController,
|
106
|
+
# If you would like to change where this engine is mounted, simply change the :at option to something different.
|
107
|
+
#
|
108
|
+
# We ask that you don't use the :as option here, as Ibrain relies on it being the default of "ibrain"
|
109
|
+
#{CORE_MOUNT_ROUTE}, at: '/'
|
110
|
+
|
111
|
+
# Please contact to Tai Nguyen Van <tainv@its-global.vn> if you have any question?
|
112
|
+
RUBY
|
116
113
|
end
|
114
|
+
end
|
117
115
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end
|
116
|
+
unless options[:quiet]
|
117
|
+
Ibrain::Logger.info "*" * 50
|
118
|
+
Ibrain::Logger.info "We added the following line to your application's config/routes.rb file:"
|
119
|
+
Ibrain::Logger.info " "
|
120
|
+
Ibrain::Logger.info " #{CORE_MOUNT_ROUTE}, at: '/'"
|
124
121
|
end
|
122
|
+
end
|
125
123
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
end
|
124
|
+
def add_files
|
125
|
+
template 'config/initializers/ibrain.rb.tt', 'config/initializers/ibrain.rb', { skip: true }
|
126
|
+
template 'config/initializers/cors.tt', 'config/initializers/cors.rb'
|
127
|
+
template 'config/puma.tt', 'config/puma.rb'
|
128
|
+
yml_template 'config/database.tt', 'config/database.yml'
|
129
|
+
template 'rubocop.yml.tt', '.rubocop.yml' if options[:with_rubocop]
|
130
|
+
|
131
|
+
if options[:with_graphql]
|
132
|
+
template 'graphql/app_schema.rb.tt', 'app/graphql/app_schema.rb', { skip: true }
|
133
|
+
template 'graphql/types/mutation_type.rb.tt', 'app/graphql/types/mutation_type.rb', { skip: true }
|
134
|
+
template 'graphql/types/query_type.rb.tt', 'app/graphql/types/query_type.rb', { skip: true }
|
138
135
|
end
|
136
|
+
end
|
139
137
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
end
|
138
|
+
def complete
|
139
|
+
unless options[:quiet]
|
140
|
+
Ibrain::Logger.info "*" * 50
|
141
|
+
Ibrain::Logger.info "Ibrain has been installed successfully. You're all ready to go!"
|
142
|
+
Ibrain::Logger.info " "
|
143
|
+
Ibrain::Logger.info "Enjoy!"
|
147
144
|
end
|
145
|
+
end
|
148
146
|
|
149
|
-
|
147
|
+
private
|
150
148
|
|
151
|
-
|
152
|
-
|
153
|
-
|
149
|
+
def bundle_cleanly(&block)
|
150
|
+
Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&block) : Bundler.with_clean_env(&block)
|
151
|
+
end
|
154
152
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
153
|
+
def append_gem(name, version, group_name = nil)
|
154
|
+
shell_command = ["\ngem '#{name}', '~> #{version}'"]
|
155
|
+
shell_command.push("group: :#{group_name}") if group_name.present?
|
156
|
+
string_command = shell_command.join(', ')
|
157
|
+
gems = Gem.loaded_specs.values.map(&:full_name).join(' ')
|
160
158
|
|
161
|
-
|
162
|
-
|
159
|
+
system( `echo "#{string_command}" >> Gemfile` ) unless gems.include?("#{name}-")
|
160
|
+
end
|
163
161
|
|
164
|
-
|
165
|
-
|
162
|
+
def remove_gem(name)
|
163
|
+
gems = Gem.loaded_specs.values.map(&:full_name).join(' ')
|
166
164
|
|
167
|
-
|
168
|
-
|
165
|
+
system( "bundle remove #{name}" ) if gems.include?("#{name}-")
|
166
|
+
end
|
169
167
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
168
|
+
def yml_template(source, *args)
|
169
|
+
config = args.last.is_a?(Hash) ? args.pop : {}
|
170
|
+
destination = args.first || source.sub(/#{TEMPLATE_EXTNAME}$/o, "")
|
171
|
+
source = File.expand_path(find_in_source_paths(source.to_s))
|
174
172
|
|
175
|
-
|
176
|
-
|
177
|
-
end
|
173
|
+
create_file destination, nil, config do
|
174
|
+
File.read(source)
|
178
175
|
end
|
179
176
|
end
|
180
177
|
end
|
@@ -1,22 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
description 'Define all mutation for client'
|
3
|
+
class Types::MutationType < Ibrain::Types::BaseApiObject
|
4
|
+
description 'Define all mutation for client'
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
# TODO: remove me
|
7
|
+
# Default session_required is true, set false if yout want to skip authenticated
|
8
|
+
field :test_authenticated_field, , String, null: false,
|
9
|
+
description: 'An example field added by the generator'
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
field :test_field, String, null: false,
|
12
|
+
description: 'An example field added by the generator', session_required: false
|
13
|
+
def test_field
|
14
|
+
'Hello World'
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
end
|
17
|
+
def test_authenticated_field
|
18
|
+
'Im logged in!'
|
21
19
|
end
|
22
20
|
end
|
@@ -1,19 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
description 'Define all resolver for client'
|
3
|
+
class Types::QueryType < Ibrain::Types::BaseApiObject
|
4
|
+
description 'Define all resolver for client'
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
# Add `node(id: ID!) and `nodes(ids: [ID!]!)`
|
7
|
+
include GraphQL::Types::Relay::HasNodeField
|
8
|
+
include GraphQL::Types::Relay::HasNodesField
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
# Add root-level fields here.
|
11
|
+
# Default session_required is true, set false if yout want to skip authenticated
|
12
|
+
# They will be entry points for queries on your schema.
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
14
|
+
# Example with user resolvers
|
15
|
+
# field :authenticated_users, resolver: Resolvers::UsersResolver
|
16
|
+
# field :users, resolver: Resolvers::UsersResolver, session_required: false
|
19
17
|
end
|