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 +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/app/graphql/ibrain/types/base_object.rb +10 -0
- data/lib/generators/ibrain/graphql/templates/object.erb +1 -1
- 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 +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49bac026eaba3fd878b761bfe99d3c91fcd738e30ac2afd66d77c6564ac5b824
|
4
|
+
data.tar.gz: a71f09ab430edd89f89b94d8abf840f5ca6239a8d3b6b8f46279898fea08c00c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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::
|
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:
|
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.
|
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-
|
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.
|
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.
|