ibrain-core 0.3.8 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8879d41d7a0776804c1864f6c103b07ea8740ae3e8b85ae42ef79b418300c109
4
- data.tar.gz: cef1d0b509b4e3269ffc693355a4a02c2923c448bc5374beb767a715312d215c
3
+ metadata.gz: 49bac026eaba3fd878b761bfe99d3c91fcd738e30ac2afd66d77c6564ac5b824
4
+ data.tar.gz: a71f09ab430edd89f89b94d8abf840f5ca6239a8d3b6b8f46279898fea08c00c
5
5
  SHA512:
6
- metadata.gz: 5992f6f7930ab1b0c6cdec1eaa664dc2da8c5632b7a34a97d162e0c531fdfdc936400f6b13210e598c5d1c6f8840a90b7e554fd49fed9fcfc153f77458b9a226
7
- data.tar.gz: 7e34198ae0d031171303a0d2b797d8e790e8bbed7712687608db74785003c26e0a304aee4d14ea6d386b9dc217d17c5009d4ee3979c97c1dd666244030def8d2
6
+ metadata.gz: 5fad906ee80ee1bb1e6e2374fdd27ba8540e9bfedf55bb6137a7991040ad88b66920a89cc85ecea236f4b91931f7743d9cc753420b48ee24199103cd2c623c8b
7
+ data.tar.gz: 233e933e270ed57eeb62c8abec0dcf024348c5c1e9a76188272f36a0ff1cf37b7c2a2d2298ba62b3eebddb9ab2c6bdf3c296329e1823857de4b859ae0760401e
@@ -23,7 +23,8 @@ module Ibrain
23
23
  controller: self,
24
24
  request: request
25
25
  },
26
- operation_name: operation_name
26
+ operation_name: operation_name,
27
+ max_depth: max_depth(operation_name)
27
28
  )
28
29
 
29
30
  render_json_ok(result['data'], nil, result['errors'])
@@ -93,6 +94,10 @@ module Ibrain
93
94
 
94
95
  request.env['devise.mapping'] = Ibrain.user_class
95
96
  end
97
+
98
+ def max_depth(operation_name)
99
+ operation_name == 'IntrospectionQuery' ? nil : Ibrain::Config.graphql_max_depth
100
+ end
96
101
  end
97
102
  end
98
103
  end
@@ -3,7 +3,9 @@
3
3
  module Ibrain
4
4
  class BaseSchema < ::GraphQL::Schema
5
5
  use GraphQL::Batch
6
+
6
7
  max_depth Ibrain::Config.graphql_max_depth
8
+ query_analyzer(Ibrain::LogQueryDepth)
7
9
 
8
10
  # use GraphQL::Guard.new(
9
11
  # policy_object: ::Ibrain::Config.graphql_policy.safe_constantize,
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Ibrain::LogQueryDepth < GraphQL::Analysis::AST::QueryDepth
4
+ def result
5
+ query_depth = super
6
+ current_user = query.context[:current_user]
7
+ message = <<-RUBY
8
+ [GraphQL Query Depth]: #{query_depth}
9
+ [UserName]: #{current_user.try(:name)}
10
+ [UserID]: #{current_user.try(:id)}
11
+ RUBY
12
+
13
+ Rails.logger.info(message)
14
+ end
15
+ end
@@ -11,6 +11,16 @@ module Ibrain
11
11
  field_class ::Ibrain::Types::BaseField
12
12
 
13
13
  field :name, String, null: true
14
+
15
+ protected
16
+
17
+ def loader
18
+ Ibrain::Loaders::AssociationLoader
19
+ end
20
+
21
+ def current_user
22
+ context.try(:fetch, :current_user)
23
+ end
14
24
  end
15
25
  end
16
26
  end
@@ -3,7 +3,7 @@
3
3
  <% module_namespacing_when_supported do -%>
4
4
  module Types
5
5
  module Objects
6
- class <%= type_ruby_name.split('::')[-1] %> < Ibrain::Types::BaseObject
6
+ class <%= type_ruby_name.split('::')[-1] %> < Ibrain::Types::BaseType
7
7
  implements Ibrain::Interfaces::RecordInterface
8
8
 
9
9
  description '<%= type_ruby_name.split('::')[-1] %>'
@@ -24,7 +24,7 @@ module Ibrain
24
24
  # @param mode [Symbol]
25
25
  # @param null [Boolean]
26
26
  # @return [(String, Boolean)] The type expression, followed by `null:` value
27
- def self.normalize_type_expression(type_expression, mode:, null: true)
27
+ def self.normalize_type_expression(type_expression, mode:, null: false)
28
28
  if type_expression.start_with?("!")
29
29
  normalize_type_expression(type_expression[1..-1], mode: mode, null: false)
30
30
  elsif type_expression.end_with?("!")
@@ -77,6 +77,7 @@ module Ibrain
77
77
  append_gem('graphql-guard', '2.0.0')
78
78
  append_gem('graphql-rails-generators', '1.1.2', 'development')
79
79
  append_gem('graphiql-rails', '1.8.0', 'development')
80
+ append_gem('apollo_upload_server', '2.1')
80
81
  end
81
82
 
82
83
  append_gem('annotate', '3.1.1', 'development') if options[:with_annotation]
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ibrain
4
- VERSION = "0.3.8"
4
+ VERSION = "0.4.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.7.rc-1'
11
+ '0.4.0'
12
12
  end
13
13
 
14
14
  def self.ibrain_gem_version
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.8
4
+ version: 0.4.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-29 00:00:00.000000000 Z
11
+ date: 2022-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-session_store
@@ -187,6 +187,7 @@ files:
187
187
  - app/graphql/ibrain/interfaces/record_interface.rb
188
188
  - app/graphql/ibrain/lazy/base.rb
189
189
  - app/graphql/ibrain/loaders/association_loader.rb
190
+ - app/graphql/ibrain/log_query_depth.rb
190
191
  - app/graphql/ibrain/mutations/base_mutation.rb
191
192
  - app/graphql/ibrain/policies/base_policy.rb
192
193
  - app/graphql/ibrain/policies/graphql_policy.rb
@@ -307,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
307
308
  - !ruby/object:Gem::Version
308
309
  version: '0'
309
310
  requirements: []
310
- rubygems_version: 3.3.7
311
+ rubygems_version: 3.3.20
311
312
  signing_key:
312
313
  specification_version: 4
313
314
  summary: Its Core is an sso authen gem for Ruby on Rails.