graphql-analyzer 0.1.2 → 0.1.3
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4b7a368bf9b13b15f3deb07a30e5852388ee533
|
4
|
+
data.tar.gz: 41b2ac8e242bf559702490e2115d69b805297eff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd93aab10263c3289d24baeedf477a0422e22c8f376f3043c4e0fbd9444667f7cd52ec6e3126e903eed410e0dcf7455fe6dc8be178e581e2d6a4b7ec4b040c78
|
7
|
+
data.tar.gz: ff215a5a7a08818b77dc0efcca5fc6dcb619a86f874c3eb2bf5ce69a1e6ee7319a5546a987e8b991c6ba3130d5617c430e35b0a8352de3bf8910dcf9d0b68590
|
data/graphql-analyzer.gemspec
CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency "factory_bot"
|
30
30
|
spec.add_development_dependency "pry-byebug"
|
31
31
|
spec.add_development_dependency "activerecord"
|
32
|
+
spec.add_development_dependency "activesupport"
|
32
33
|
spec.add_development_dependency "mysql2"
|
33
34
|
spec.add_development_dependency "sqlite3"
|
34
35
|
spec.add_development_dependency "pg", "~> 0.18"
|
data/lib/graphql/analyzer.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "graphql"
|
2
2
|
require "graphql/analyzer/version"
|
3
3
|
require "graphql/analyzer/instrumentation/base"
|
4
|
+
require "graphql/analyzer/instrumentation/elastic_search"
|
4
5
|
require "graphql/analyzer/instrumentation/mysql"
|
5
6
|
require "graphql/analyzer/instrumentation/postgresql"
|
6
7
|
require "graphql/analyzer/instrumentation/sqlite3"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module GraphQL
|
2
|
+
class Analyzer
|
3
|
+
module Instrumentation
|
4
|
+
class ElasticSearch
|
5
|
+
def initialize
|
6
|
+
@notifications = []
|
7
|
+
ActiveSupport::Notifications.subscribe('search.elasticsearch') do |name, start, finish, id, payload|
|
8
|
+
@notifications << {
|
9
|
+
name: name,
|
10
|
+
start: start,
|
11
|
+
finish: finish,
|
12
|
+
id: id,
|
13
|
+
payload: payload
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def instrument(type, field)
|
19
|
+
->(obj, args, ctx) do
|
20
|
+
result = field.resolve_proc.call(obj, args, ctx)
|
21
|
+
|
22
|
+
if @notifications.any?
|
23
|
+
# TODO: Merge results when a field makes two types of queries
|
24
|
+
# e.g. path: ['user', 'name'] makes a SQL and ES Query.
|
25
|
+
ctx['graphql-analyzer']['resolvers'] << {
|
26
|
+
'path' => ctx.path,
|
27
|
+
'adapter' => 'elasticsearch',
|
28
|
+
'parentType' => type.name,
|
29
|
+
'fieldName' => field.name,
|
30
|
+
'returnType' => field.type.to_s,
|
31
|
+
'details' => @notifications
|
32
|
+
}
|
33
|
+
|
34
|
+
@notifications = []
|
35
|
+
end
|
36
|
+
|
37
|
+
result
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DerekStride
|
@@ -114,6 +114,20 @@ dependencies:
|
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: activesupport
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
117
131
|
- !ruby/object:Gem::Dependency
|
118
132
|
name: mysql2
|
119
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -186,6 +200,7 @@ files:
|
|
186
200
|
- graphql-analyzer.gemspec
|
187
201
|
- lib/graphql/analyzer.rb
|
188
202
|
- lib/graphql/analyzer/instrumentation/base.rb
|
203
|
+
- lib/graphql/analyzer/instrumentation/elastic_search.rb
|
189
204
|
- lib/graphql/analyzer/instrumentation/mysql.rb
|
190
205
|
- lib/graphql/analyzer/instrumentation/postgresql.rb
|
191
206
|
- lib/graphql/analyzer/instrumentation/sqlite3.rb
|