ibrain-core 0.3.3 → 0.3.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/core/graphql_controller.rb +3 -3
- data/app/graphql/ibrain/resolvers/base_aggregate.rb +1 -1
- data/app/graphql/ibrain/types/aggregate_type.rb +3 -1
- data/app/graphql/ibrain/types/base_api_connection.rb +2 -2
- data/app/graphql/ibrain/types/base_connection.rb +3 -3
- data/app/graphql/ibrain/types/base_object.rb +8 -0
- data/app/models/ibrain/aggregate.rb +11 -0
- data/lib/generators/ibrain/graphql/object_generator.rb +1 -1
- data/lib/generators/ibrain/graphql/templates/input.erb +1 -1
- data/lib/generators/ibrain/graphql/templates/mutation.erb +1 -1
- data/lib/generators/ibrain/install/templates/config/initializers/ibrain.rb.tt +3 -0
- data/lib/ibrain/app_configuration.rb +2 -0
- data/lib/ibrain/core/version.rb +2 -2
- data/lib/tasks/ibrain/ridgepole.rake +5 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce7566a45bf8104c5716af6292a1c42310a04b6816b39344f150af14f1dd021b
|
4
|
+
data.tar.gz: b0dad36cd1f5d34c7e3ba1de7eed8a75be9c6eae6fc2338942010da8212f1724
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9059a3849ba826fe227d13a6cfb85ee5f6753e49aed78bf1b92a268e7181472293375cfdb134cd1bb2179c0ac8305d6b6a3dd14ddc3003e0be16111f3f248c12
|
7
|
+
data.tar.gz: 57a41af75b233f6de3376a3918fca42f46e84c7fa50eec9796244e136018e794625bd7243285efb6232c6d6ca3636b5d7563e5df03be7be74f76a50c8311cae6
|
@@ -36,9 +36,9 @@ module Ibrain
|
|
36
36
|
return [params[:query], prepare_variables(params[:variables]), 'IntrospectionQuery'] if params[:query].try(:include?, 'IntrospectionQuery')
|
37
37
|
|
38
38
|
operations = prepare_variables(params[:operations])
|
39
|
-
query = operations['query']
|
40
|
-
variables = operations['variables']
|
41
|
-
operation_name = operations['operationName']
|
39
|
+
query = operations['query'] || params[:query]
|
40
|
+
variables = operations['variables'] || params[:variables]
|
41
|
+
operation_name = operations['operationName'] || params[:operationName]
|
42
42
|
|
43
43
|
if params[:map].present?
|
44
44
|
JSON.parse(params[:map]).each do |k, arguments|
|
@@ -6,9 +6,9 @@ module Ibrain
|
|
6
6
|
# add `nodes` and `pageInfo` fields, as well as `edge_type(...)` and `node_nullable(...)` overrides
|
7
7
|
include GraphQL::Types::Relay::ConnectionBehaviors
|
8
8
|
|
9
|
-
field :
|
9
|
+
field :count, Integer, null: false, camelize: false
|
10
10
|
|
11
|
-
def
|
11
|
+
def count
|
12
12
|
object.items.size
|
13
13
|
end
|
14
14
|
end
|
@@ -6,10 +6,10 @@ module Ibrain
|
|
6
6
|
# add `nodes` and `pageInfo` fields, as well as `edge_type(...)` and `node_nullable(...)` overrides
|
7
7
|
include GraphQL::Types::Relay::ConnectionBehaviors
|
8
8
|
|
9
|
-
field :
|
9
|
+
field :aggregate, Ibrain::Types::AggregateType, null: false, camelize: false
|
10
10
|
|
11
|
-
def
|
12
|
-
object.
|
11
|
+
def aggregate
|
12
|
+
Ibrain::Aggregate.new(object.uniq.size)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -9,6 +9,14 @@ module Ibrain
|
|
9
9
|
connection_type_class(Ibrain::Types::BaseConnection)
|
10
10
|
|
11
11
|
field_class ::Ibrain::Types::BaseField
|
12
|
+
|
13
|
+
def self.overridden_graphql_name(name = '')
|
14
|
+
to_s.demodulize.gsub('Type', '').singularize.classify.constantize.table_name
|
15
|
+
rescue StandardError
|
16
|
+
return to_s.demodulize if name.blank?
|
17
|
+
|
18
|
+
name
|
19
|
+
end
|
12
20
|
end
|
13
21
|
end
|
14
22
|
end
|
@@ -32,7 +32,7 @@ module Ibrain
|
|
32
32
|
create_dir('app/repositories') unless Dir.exist?('app/repositories')
|
33
33
|
|
34
34
|
template "object.erb", "#{options[:directory]}/types/objects/#{type_file_name}.rb"
|
35
|
-
template "input.erb", "#{options[:directory]}/types/
|
35
|
+
template "input.erb", "#{options[:directory]}/types/attributes/#{input_file_name}.rb"
|
36
36
|
template "repository.erb", "app/repositories/#{type_name}_repository.rb"
|
37
37
|
end
|
38
38
|
|
@@ -11,7 +11,7 @@ module Mutations
|
|
11
11
|
|
12
12
|
# TODO: define arguments
|
13
13
|
# argument :name, String, required: true
|
14
|
-
# argument :<%= model_name.underscore %>, Types::
|
14
|
+
# argument :<%= model_name.underscore %>, Types::Attributes::<%= model_name %>Input, required: true
|
15
15
|
|
16
16
|
# TODO: define resolve method
|
17
17
|
def resolve(args)
|
@@ -51,6 +51,8 @@ module Ibrain
|
|
51
51
|
# Parent controller
|
52
52
|
preference :parent_controller, :string, default: 'ActionController::API'
|
53
53
|
|
54
|
+
preference :master_database, :string, default: 'primary'
|
55
|
+
|
54
56
|
def static_model_preferences
|
55
57
|
@static_model_preferences ||= Ibrain::Preferences::StaticModelPreferences.new
|
56
58
|
end
|
data/lib/ibrain/core/version.rb
CHANGED
@@ -3,7 +3,11 @@
|
|
3
3
|
namespace :ridgepole do
|
4
4
|
desc 'Apply database schema'
|
5
5
|
task apply: :environment do
|
6
|
-
|
6
|
+
databases = Rails.configuration.database_configuration.fetch(Rails.env, {}).keys
|
7
|
+
primary_database = Ibrain::Config.master_database
|
8
|
+
spec_option = databases.include?(primary_database) ? "--spec-name primary #{primary_database}" : ""
|
9
|
+
|
10
|
+
ridgepole('--apply', "-E #{Rails.env}", "--file #{schema_file}", spec_option)
|
7
11
|
Rake::Task['db:schema:dump'].invoke if Rails.env.development?
|
8
12
|
Rake::Task['annotate_models'].invoke if Rails.env.development?
|
9
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibrain-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tai Nguyen Van
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-session_store
|
@@ -218,6 +218,7 @@ files:
|
|
218
218
|
- app/models/concerns/ibrain/user_api_authentication.rb
|
219
219
|
- app/models/concerns/ibrain/user_methods.rb
|
220
220
|
- app/models/ibrain/ability.rb
|
221
|
+
- app/models/ibrain/aggregate.rb
|
221
222
|
- app/models/ibrain/application_record.rb
|
222
223
|
- app/models/ibrain/base.rb
|
223
224
|
- app/models/ibrain/legacy_user.rb
|