graphql-analyzer 0.1.1 → 0.1.2
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: 495b6fc8f408e0e735bba5da4c41d0f5e2ccabeb
|
4
|
+
data.tar.gz: 1aac9d6076edeb2a18fa860de1bb8075ee6b7f4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81b1e60dd96bbbe51d5e22dc1082b79525d3230fb2ead1c7c58a464f83613fea5c37e3afa1b94abe296d0ecb4d91a37606f05afec68e3b157c41b0ce0b85b9e8
|
7
|
+
data.tar.gz: 87aa1755c052f2a6450b9c26a8d541969ff09d591bbe7744366d5a5e6c7e0007dafdb47fbc9df8f49df174820783f63659c12dfb880d2252e32d9f9e54d94ead
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# GraphQL::Analyzer
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/GraphQL-Query-Planner/graphql-analyzer.svg?branch=master)](https://travis-ci.org/GraphQL-Query-Planner/graphql-analyzer)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/graphql-analyzer.svg)](https://rubygems.org/gems/graphql-analyzer)
|
5
|
+
|
4
6
|
|
5
7
|
GraphQL Analyzer is a [GraphQL](https://github.com/rmosolgo/graphql-ruby) extension for tracking datastore queries.
|
6
8
|
|
@@ -5,15 +5,25 @@ module GraphQL
|
|
5
5
|
private
|
6
6
|
|
7
7
|
def parse
|
8
|
-
|
9
|
-
|
8
|
+
explained_output_by_query = explain_output.split(/^EXPLAIN.*$/).map(&:chomp).reject(&:empty?)
|
9
|
+
queries = explain_output.split("\n").select { |l| l =~ /^EXPLAIN.*$/ }
|
10
|
+
|
11
|
+
results = []
|
12
|
+
queries.each.with_index do |query, i|
|
13
|
+
keys, *values, _ = explained_output_by_query[i]
|
14
|
+
.split("\n")
|
15
|
+
.map(&:chomp)
|
16
|
+
.reject { |line| line.empty? || line =~ /^\+.*\+$/ }
|
17
|
+
fields = keys[1..-1].split('|').map(&:strip).map(&:downcase)
|
10
18
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
19
|
+
explained_queries = values.map do |value|
|
20
|
+
parsed_value = value[1..-1].split("|").map(&:strip)
|
21
|
+
fields.zip(parsed_value).to_h
|
22
|
+
end
|
15
23
|
|
16
|
-
|
24
|
+
results << Result.new(query, explained_queries)
|
25
|
+
end
|
26
|
+
results
|
17
27
|
end
|
18
28
|
end
|
19
29
|
end
|
@@ -9,7 +9,7 @@ module GraphQL
|
|
9
9
|
def parse
|
10
10
|
root, *values = explain_output.split("\n")
|
11
11
|
explained_queries = values.map { |value| FIELDS.zip(value.split("|").map(&:strip)).to_h }
|
12
|
-
Result.new(root, explained_queries)
|
12
|
+
[Result.new(root, explained_queries)]
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DerekStride
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|