activecube-graphql 0.1.14 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -7
- data/lib/activecube/graphql/parse_tree.rb +34 -8
- data/lib/activecube/graphql/response_builder.rb +9 -10
- data/lib/activecube/graphql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b25aea2427a180585cadd733facfca3fd3b97c6b409caf4bbc0c19242811e1ab
|
4
|
+
data.tar.gz: 83ad80ea19246880867da2b9ff022ef7610ae44e8833b9371afd3a4c94bc601e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59e2e1038ec25b78146307ba94b9290c2d505039b3354ad3d7b7d30ee8fc2ba899bb78e1c9a5a3f417be0f9a1bc0bd442cce271680d2469d475c4b63c8b8ad6c
|
7
|
+
data.tar.gz: 17765551a7dac697c1d2a4a05106621b68da6c331646da30f646d7e5b49e0f7065ddc74fa2efde7b22cd80da2b1257451beea765305813e6e6c18e0ee5c8aaee
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
activecube-graphql (0.1.
|
5
|
-
activecube (~> 0.1.
|
4
|
+
activecube-graphql (0.1.18)
|
5
|
+
activecube (~> 0.1.28)
|
6
6
|
graphql (~> 1.10)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activecube (0.1.
|
11
|
+
activecube (0.1.30)
|
12
12
|
activerecord (>= 5.2)
|
13
13
|
activemodel (6.0.3.1)
|
14
14
|
activesupport (= 6.0.3.1)
|
@@ -21,12 +21,12 @@ GEM
|
|
21
21
|
minitest (~> 5.1)
|
22
22
|
tzinfo (~> 1.1)
|
23
23
|
zeitwerk (~> 2.2, >= 2.2.2)
|
24
|
-
concurrent-ruby (1.1.
|
24
|
+
concurrent-ruby (1.1.7)
|
25
25
|
diff-lcs (1.3)
|
26
26
|
graphql (1.11.0)
|
27
27
|
i18n (1.8.5)
|
28
28
|
concurrent-ruby (~> 1.0)
|
29
|
-
minitest (5.14.
|
29
|
+
minitest (5.14.2)
|
30
30
|
rake (13.0.1)
|
31
31
|
rspec (3.9.0)
|
32
32
|
rspec-core (~> 3.9.0)
|
@@ -42,9 +42,9 @@ GEM
|
|
42
42
|
rspec-support (~> 3.9.0)
|
43
43
|
rspec-support (3.9.3)
|
44
44
|
thread_safe (0.3.6)
|
45
|
-
tzinfo (1.2.
|
45
|
+
tzinfo (1.2.8)
|
46
46
|
thread_safe (~> 0.1)
|
47
|
-
zeitwerk (2.4.
|
47
|
+
zeitwerk (2.4.2)
|
48
48
|
|
49
49
|
PLATFORMS
|
50
50
|
ruby
|
@@ -6,6 +6,7 @@ module Activecube
|
|
6
6
|
|
7
7
|
TYPENAME = '__typename'
|
8
8
|
KEY_FIELD_PREFIX = '_aq.'
|
9
|
+
NULLABLE_OPERATORS = [:eq,:not_eq,:is,:not]
|
9
10
|
|
10
11
|
attr_reader :arguments, :ast_node, :cube, :parent, :name, :definition, :key,
|
11
12
|
:children, :metric, :dimension, :field, :context_node
|
@@ -18,10 +19,11 @@ module Activecube
|
|
18
19
|
@key = parent ? (parent.key ? "#{parent.key}.#{name}" : KEY_FIELD_PREFIX+name ) : nil
|
19
20
|
|
20
21
|
@context_node = context_node
|
21
|
-
@arguments = context_node.arguments.to_h
|
22
|
-
|
23
22
|
@ast_node = context_node.ast_node
|
24
23
|
|
24
|
+
@arguments = sort_node_arguments ast_node, context_node.arguments.to_h
|
25
|
+
|
26
|
+
|
25
27
|
if parent
|
26
28
|
@definition = context_node.definitions.first.name
|
27
29
|
if parent.dimension
|
@@ -43,6 +45,22 @@ module Activecube
|
|
43
45
|
|
44
46
|
end
|
45
47
|
|
48
|
+
def sort_node_arguments ast_node, arguments
|
49
|
+
if (options = arguments['options']).kind_of?(Hash)
|
50
|
+
options_keys = context_node.ast_node.arguments.detect{|x| x.name=='options'}.value.arguments.map{|x|
|
51
|
+
x.name.underscore.to_sym
|
52
|
+
}
|
53
|
+
arguments['options'] = Hash[
|
54
|
+
options_keys.collect{|key|
|
55
|
+
raise "Unmatched key #{key}" unless options[key]
|
56
|
+
[key, options[key]]
|
57
|
+
}
|
58
|
+
|
59
|
+
]
|
60
|
+
end
|
61
|
+
arguments
|
62
|
+
end
|
63
|
+
|
46
64
|
def union?
|
47
65
|
context_node.return_type.kind_of? GraphQL::UnionType
|
48
66
|
end
|
@@ -98,23 +116,31 @@ module Activecube
|
|
98
116
|
element
|
99
117
|
end
|
100
118
|
|
119
|
+
|
101
120
|
def converted_field_array method, values
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
121
|
+
case method
|
122
|
+
when :desc,:asc
|
123
|
+
values.collect{|v| KEY_FIELD_PREFIX + v}
|
124
|
+
when :limit_by
|
125
|
+
values.merge({each: KEY_FIELD_PREFIX + values[:each]})
|
126
|
+
else
|
127
|
+
values
|
128
|
+
end
|
107
129
|
end
|
108
130
|
|
109
131
|
def apply_selector element, k, hash
|
110
132
|
hash.each_pair do |operator, arg|
|
111
133
|
selector = cube.selectors[k]
|
112
134
|
raise Activecube::InputArgumentError, "#{selector} does not handle method '#{operator}' for #{element} '#{k}'" unless selector.respond_to?(operator)
|
113
|
-
element = element.when( selector.send(operator, arg) )
|
135
|
+
element = element.when( selector.send(operator, arg) ) if applicable_operator?(operator, arg)
|
114
136
|
end
|
115
137
|
element
|
116
138
|
end
|
117
139
|
|
140
|
+
def applicable_operator? operator, arg
|
141
|
+
!arg.nil? || NULLABLE_OPERATORS.include?(operator)
|
142
|
+
end
|
143
|
+
|
118
144
|
def apply_or_selector element, value
|
119
145
|
selectors = value.collect{|v| make_selector v }.compact
|
120
146
|
element.when( Activecube::Query::Selector.or(selectors) )
|
@@ -18,6 +18,10 @@ module Activecube::Graphql
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def __typename
|
22
|
+
raise Activecube::InputArgumentError, "Add __typename to the element for UNION or INTERFACE entity to resolve the type"
|
23
|
+
end
|
24
|
+
|
21
25
|
end
|
22
26
|
|
23
27
|
|
@@ -117,21 +121,16 @@ module Activecube::Graphql
|
|
117
121
|
node_type element
|
118
122
|
else
|
119
123
|
tuple = element.metric.definition.class.tuple
|
120
|
-
|
121
|
-
|
122
|
-
element.children.collect{|a|
|
123
|
-
[a.name, node_type(a)]
|
124
|
-
}.sort_by{|x| tuple.index x.first.to_sym }
|
125
|
-
|
124
|
+
element.children.collect{|a| [ a.name, node_type(a), tuple.index(a.name.to_sym)] }
|
126
125
|
end
|
127
126
|
|
128
127
|
response_class.class_eval do
|
129
128
|
define_method definition.underscore do |**rest_of_options|
|
130
129
|
@row[index].map{|array_obj|
|
131
|
-
if array_obj.kind_of?(Array) && array_element_type.kind_of?(Array)
|
132
|
-
Hash[
|
133
|
-
|
134
|
-
[etype.first.underscore, convert_type(etype.second,
|
130
|
+
if array_obj.kind_of?(Array) && array_element_type.kind_of?(Array)
|
131
|
+
Hash[
|
132
|
+
array_element_type.map{|etype|
|
133
|
+
[etype.first.underscore, convert_type(etype.second, array_obj[etype.third])]
|
135
134
|
}]
|
136
135
|
elsif !array_obj.kind_of?(Array) && array_element_type.kind_of?(String)
|
137
136
|
convert_type(array_element_type, obj)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activecube-graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksey Studnev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activecube
|