ibrain-core 0.3.3 → 0.3.6.pre.rc.1

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: cdd2900870960f51ee9c9624ca4bf0e7d559ee292b695efd880fe11a7f0fc0bf
4
- data.tar.gz: 9cdc61fafdfe8d61bf5751553f417b040695a76c27116812ebeaf262880ef323
3
+ metadata.gz: b1e030506b77afbbd1a195a04ce3887a4ca3b2331cba1963985c6d93577f78b3
4
+ data.tar.gz: 2c4fc926524af27183fc2fec91f6eb3ba301caba1b46ecbdd89c71337d05da0d
5
5
  SHA512:
6
- metadata.gz: b8189a8d833bd50db18abfcd2ed807b5c0a59ec9329e92fe6d5fdc2f490777d002bc6befe36bf659fc68887976069adfa84d8217a87e1259aea3eec4b8633b4f
7
- data.tar.gz: c93b51ea486b814e7a3ce5baf59f3478e632ca104b3e7772b30e2910db4e76acb79f28ac7213167cd22952accda98ce89a7a7d4db173c68e03591443ffd79cc6
6
+ metadata.gz: 7014646c14b98c4435e3a75362367eb5f5ee699f065ab92e7afd166d4a87fdcd9d3faae83461aec70e07812416999b0457646f8c72ebc2255733fb1e8942d31f
7
+ data.tar.gz: e23e0af4d959ee2e1e5e4d424a52cb0288208697c295069d66e37e8091d1e08d3ed338303c5fba847178f1428a6fa4bb3d1f6eae9bb3b31290d0532930d8e83d
@@ -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|
@@ -3,7 +3,7 @@
3
3
  module Ibrain
4
4
  module Resolvers
5
5
  class BaseAggregate < BaseResolver
6
- type Ibrain::Types::AggregateType.connection_type, null: false
6
+ type Ibrain::Types::BaseObject.connection_type, null: false
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,9 @@
3
3
  module Ibrain
4
4
  module Types
5
5
  class AggregateType < BaseObject
6
- field :total_count, Int, null: false, default_value: 0
6
+ graphql_name 'aggregate'
7
+
8
+ field :count, Int, null: false
7
9
  end
8
10
  end
9
11
  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 :total_count, Integer, null: false, camelize: false
9
+ field :aggregate, Ibrain::Types::AggregateType, null: false, camelize: false
10
10
 
11
- def total_count
12
- object.items.size
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::BaseApiConnection)
10
10
 
11
11
  field_class Ibrain::Types::BaseApiField
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
@@ -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 :total_count, Integer, null: false, camelize: false
9
+ field :aggregate, Ibrain::Types::AggregateType, null: false, camelize: false
10
10
 
11
- def total_count
12
- object.items.size
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
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ibrain
4
+ class Aggregate
5
+ def initialize(count)
6
+ @count = count
7
+ end
8
+
9
+ attr_reader :count
10
+ end
11
+ 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/input/#{input_file_name}.rb"
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
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  <% module_namespacing_when_supported do -%>
4
4
  module Types
5
- module Input
5
+ module Attributes
6
6
  class <%= input_ruby_name.split('::')[-1] %> < Ibrain::Types::BaseInputObject
7
7
  description '<%= input_ruby_name.split('::')[-1] %>'
8
8
 
@@ -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::Input::<%= model_name %>Input, required: true
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)
@@ -44,6 +44,9 @@ Ibrain.config do |config|
44
44
 
45
45
  # Parent controller
46
46
  # config.parent_controller = 'ActionController::API'
47
+
48
+ # For multiple database
49
+ preference :master_database, :string, default: 'primary'
47
50
  end
48
51
 
49
52
  <% if defined?(Ibrain::Api::Engine) -%>
@@ -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
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ibrain
4
- VERSION = "0.3.3"
4
+ VERSION = "0.3.6-rc.1"
5
5
 
6
6
  def self.ibrain_version
7
7
  VERSION
8
8
  end
9
9
 
10
10
  def self.previous_ibrain_minor_version
11
- '0.3.2-rc.4'
11
+ '0.3.6'
12
12
  end
13
13
 
14
14
  def self.ibrain_gem_version
@@ -3,7 +3,11 @@
3
3
  namespace :ridgepole do
4
4
  desc 'Apply database schema'
5
5
  task apply: :environment do
6
- ridgepole('--apply', "-E #{Rails.env}", "--file #{schema_file}")
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.3
4
+ version: 0.3.6.pre.rc.1
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-24 00:00:00.000000000 Z
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
@@ -301,9 +302,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
301
302
  version: '0'
302
303
  required_rubygems_version: !ruby/object:Gem::Requirement
303
304
  requirements:
304
- - - ">="
305
+ - - ">"
305
306
  - !ruby/object:Gem::Version
306
- version: '0'
307
+ version: 1.3.1
307
308
  requirements: []
308
309
  rubygems_version: 3.3.7
309
310
  signing_key: