ibrain-core 0.3.8 → 0.3.9
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 +6 -1
- data/app/graphql/ibrain/base_schema.rb +2 -0
- data/app/graphql/ibrain/log_query_depth.rb +15 -0
- data/lib/generators/ibrain/graphql/type_generator.rb +1 -1
- data/lib/generators/ibrain/install/install_generator.rb +1 -0
- data/lib/ibrain/core/version.rb +2 -2
- 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: 54aa7f0b5250da9ca3b9855824c529007a2c01cbc12eaf63347298261c1422e7
|
4
|
+
data.tar.gz: 0c1f05cba8a7817f84b8c4cb85953ff5feea2f2a5753cda6a486498426133bb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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:
|
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]
|
data/lib/ibrain/core/version.rb
CHANGED
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.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-
|
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
|