graphiti_gql 0.2.9 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -8
- data/lib/graphiti_gql/active_resource.rb +18 -14
- data/lib/graphiti_gql/schema/list_arguments.rb +9 -1
- data/lib/graphiti_gql/spec_helper.rb +7 -3
- data/lib/graphiti_gql/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: 738c0d01e7e5491204399c4ddf9b0d346943555c49a1b64937e62c4503a23d9b
|
4
|
+
data.tar.gz: 80837b0265bcfda82c95bb498e262f52208a75a06b61670df342aea53d16ceb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ad649a5f015c967529be572ad5f586edbeeb83205aaf4421c0f8906099213565492ba54f871e141aee37a668d5255cfa7188429cbbb15484d11af20c2b70cbe
|
7
|
+
data.tar.gz: b1b6812f8e4f350682124de0dfefde997602ed41f6d7b5e704ae640d2e59636c789e1ba54c75a51ef5beea41fbd76d3213424736d7159f455aad27bd6323361d
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
graphiti_gql (0.2.
|
4
|
+
graphiti_gql (0.2.11)
|
5
5
|
graphiti (~> 1.3.9)
|
6
6
|
graphql (~> 2.0)
|
7
7
|
graphql-batch (~> 0.5)
|
@@ -20,15 +20,11 @@ GEM
|
|
20
20
|
coderay (1.1.3)
|
21
21
|
concurrent-ruby (1.1.10)
|
22
22
|
diff-lcs (1.5.0)
|
23
|
-
dry-
|
23
|
+
dry-container (0.10.0)
|
24
24
|
concurrent-ruby (~> 1.0)
|
25
|
-
|
26
|
-
dry-container (0.9.0)
|
25
|
+
dry-core (0.8.0)
|
27
26
|
concurrent-ruby (~> 1.0)
|
28
|
-
|
29
|
-
dry-core (0.7.1)
|
30
|
-
concurrent-ruby (~> 1.0)
|
31
|
-
dry-inflector (0.2.1)
|
27
|
+
dry-inflector (0.3.0)
|
32
28
|
dry-logic (1.2.0)
|
33
29
|
concurrent-ruby (~> 1.0)
|
34
30
|
dry-core (~> 0.5, >= 0.5)
|
@@ -47,7 +47,7 @@ module GraphitiGql
|
|
47
47
|
end
|
48
48
|
|
49
49
|
class Proxy
|
50
|
-
def initialize(resource, params, ctx, query)
|
50
|
+
def initialize(resource, params, ctx, query, options = {})
|
51
51
|
@query = query
|
52
52
|
@resource = resource
|
53
53
|
@ctx = ctx
|
@@ -56,6 +56,7 @@ module GraphitiGql
|
|
56
56
|
sort[:att] = sort[:att].to_s.camelize(:lower)
|
57
57
|
sort[:dir] = sort[:dir].to_s
|
58
58
|
end
|
59
|
+
@with_pagination = !!options[:with_pagination]
|
59
60
|
end
|
60
61
|
|
61
62
|
def to_h(symbolize_keys: true)
|
@@ -76,7 +77,7 @@ module GraphitiGql
|
|
76
77
|
else
|
77
78
|
data[data.keys.first][:nodes] || []
|
78
79
|
end
|
79
|
-
elements.map { |n| Node.new(underscore(n), @resource) }
|
80
|
+
elements.compact.map { |n| Node.new(underscore(n), @resource) }
|
80
81
|
end
|
81
82
|
alias :to_a :nodes
|
82
83
|
|
@@ -118,7 +119,7 @@ module GraphitiGql
|
|
118
119
|
|
119
120
|
name = Schema.registry.key_for(@resource)
|
120
121
|
sortvar = "$sort: [#{name}Sort!]," if @resource.sorts.any?
|
121
|
-
filter_bang = "!" if @resource.filters.values.any? { |f| f[:required] }
|
122
|
+
filter_bang = "!" if @resource.grouped_filters.any? || @resource.filters.values.any? { |f| f[:required] }
|
122
123
|
filtervar = "$filter: #{name}Filter#{filter_bang}," if @resource.filters.any?
|
123
124
|
|
124
125
|
if !(fields = @params[:fields])
|
@@ -207,15 +208,18 @@ module GraphitiGql
|
|
207
208
|
end
|
208
209
|
end
|
209
210
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
211
|
+
q << %|
|
212
|
+
}
|
213
|
+
}|
|
214
|
+
if @with_pagination
|
215
|
+
q << %|
|
216
|
+
pageInfo {
|
217
|
+
startCursor
|
218
|
+
endCursor
|
219
|
+
hasNextPage
|
220
|
+
hasPreviousPage
|
221
|
+
}|
|
222
|
+
end
|
219
223
|
|
220
224
|
if @params[:stats]
|
221
225
|
q << %|
|
@@ -251,8 +255,8 @@ module GraphitiGql
|
|
251
255
|
end
|
252
256
|
|
253
257
|
class_methods do
|
254
|
-
def gql(params = {}, ctx = {}, query = nil)
|
255
|
-
Proxy.new(self, params, ctx, query)
|
258
|
+
def gql(params = {}, ctx = {}, query = nil, opts = {})
|
259
|
+
Proxy.new(self, params, ctx, query, opts)
|
256
260
|
end
|
257
261
|
end
|
258
262
|
end
|
@@ -36,6 +36,7 @@ module GraphitiGql
|
|
36
36
|
value
|
37
37
|
end
|
38
38
|
}
|
39
|
+
required = true if @resource.grouped_filters.any? && !@sideload
|
39
40
|
field.argument :filter, filter_type, required: required
|
40
41
|
end
|
41
42
|
|
@@ -46,11 +47,18 @@ module GraphitiGql
|
|
46
47
|
end
|
47
48
|
klass = Class.new(GraphQL::Schema::InputObject)
|
48
49
|
klass.graphql_name type_name
|
50
|
+
required_via_group = []
|
51
|
+
if (group = @resource.grouped_filters).present?
|
52
|
+
if group[:required] == :all
|
53
|
+
required_via_group = group[:names].map(&:to_sym)
|
54
|
+
end
|
55
|
+
end
|
49
56
|
@resource.filters.each_pair do |name, config|
|
50
57
|
attr_type = generate_filter_attribute_type(type_name, name, config)
|
58
|
+
required = !!config[:required] || required_via_group.include?(name)
|
51
59
|
klass.argument name.to_s.camelize(:lower),
|
52
60
|
attr_type,
|
53
|
-
required:
|
61
|
+
required: required
|
54
62
|
end
|
55
63
|
registry[type_name] = { type: klass }
|
56
64
|
klass
|
@@ -69,13 +69,17 @@ module GraphitiGql
|
|
69
69
|
|
70
70
|
def proxy
|
71
71
|
q = defined?(query) ? query : nil
|
72
|
-
|
72
|
+
with_pagination = respond_to?(:with_pagination) ? send(:with_pagination) : false
|
73
|
+
opts = { with_pagination: with_pagination }
|
74
|
+
resource.gql(params.merge(fields: fields), ctx, q, opts)
|
73
75
|
end
|
74
76
|
|
77
|
+
|
75
78
|
def run
|
76
79
|
lambda do
|
77
|
-
proxy
|
78
|
-
|
80
|
+
instance = proxy
|
81
|
+
instance.to_h
|
82
|
+
instance
|
79
83
|
end
|
80
84
|
end
|
81
85
|
|
data/lib/graphiti_gql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphiti_gql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|