ibrain-core 0.3.8 → 0.3.9

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: 8879d41d7a0776804c1864f6c103b07ea8740ae3e8b85ae42ef79b418300c109
4
- data.tar.gz: cef1d0b509b4e3269ffc693355a4a02c2923c448bc5374beb767a715312d215c
3
+ metadata.gz: 54aa7f0b5250da9ca3b9855824c529007a2c01cbc12eaf63347298261c1422e7
4
+ data.tar.gz: 0c1f05cba8a7817f84b8c4cb85953ff5feea2f2a5753cda6a486498426133bb7
5
5
  SHA512:
6
- metadata.gz: 5992f6f7930ab1b0c6cdec1eaa664dc2da8c5632b7a34a97d162e0c531fdfdc936400f6b13210e598c5d1c6f8840a90b7e554fd49fed9fcfc153f77458b9a226
7
- data.tar.gz: 7e34198ae0d031171303a0d2b797d8e790e8bbed7712687608db74785003c26e0a304aee4d14ea6d386b9dc217d17c5009d4ee3979c97c1dd666244030def8d2
6
+ metadata.gz: 9ced3c27494f81a998bb7c6960141c58ce8902b44199668e63986771db01a5f033b4d59cf7a5518fc9f3442111582a8b7791e6f2e6700a0204b175132effb23a
7
+ data.tar.gz: d4f72b228c824b4fb68afa420a2caba8180e362ad35dcb154d81faf61fb420569407d7a4abc8f3637ae90b9ba10de3606e4687d6ee809d5281c9de34d45d0f8f
@@ -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' ? 100 : 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
@@ -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.3.9"
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.3.8'
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.3.9
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-01 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