graphiti_gql 0.2.19 → 0.2.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/graphiti_gql.gemspec +1 -1
- data/lib/graphiti_gql/active_resource.rb +1 -0
- data/lib/graphiti_gql/graphiti_hax.rb +58 -5
- data/lib/graphiti_gql/version.rb +1 -1
- data/lib/graphiti_gql.rb +1 -0
- metadata +22 -18
- data/app/controllers/graphiti_gql/execution_controller.rb +0 -18
- data/config/routes.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a79d794e346a1f884170026503f4ca36a5c82529a47dd977b34335457d4a630
|
4
|
+
data.tar.gz: 0ee188c2f278895a47b27c8dbe57b1117dfe352350a99bec8a908702cc782411
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4eb9c8bb29c513cc9b8eed6e7dafffbefa1de88ab9e1dbc32d1f921b0664ee066c671d36c05eeb15614accded9ba56d4247010ea9c83bf55e0f76ae4d036b31
|
7
|
+
data.tar.gz: 014ee03255a4c2b26bbe178d6c60f4f071955a288dac725aa75ae84dcd6624bde251442ea3f7e7811bae4ec9b7f463f024cdcc5c3c4f6f90ec8575e7eb071999
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
graphiti_gql (0.2.
|
4
|
+
graphiti_gql (0.2.21)
|
5
|
+
activemodel (> 6.0, < 8.0)
|
5
6
|
graphiti (~> 1.3.9)
|
6
7
|
graphql (~> 2.0)
|
7
8
|
graphql-batch (~> 0.5)
|
@@ -82,7 +83,6 @@ PLATFORMS
|
|
82
83
|
arm64-darwin-21
|
83
84
|
|
84
85
|
DEPENDENCIES
|
85
|
-
activemodel (~> 7.0)
|
86
86
|
bundler (~> 2.3)
|
87
87
|
graphiti_gql!
|
88
88
|
pry
|
data/graphiti_gql.gemspec
CHANGED
@@ -38,9 +38,9 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_dependency "graphql", "~> 2.0"
|
39
39
|
spec.add_dependency "graphql-batch", "~> 0.5"
|
40
40
|
spec.add_dependency "graphiti", "~> 1.3.9"
|
41
|
+
spec.add_dependency "activemodel", ["> 6.0", "< 8.0"]
|
41
42
|
|
42
43
|
spec.add_development_dependency "bundler", "~> 2.3"
|
43
44
|
spec.add_development_dependency "rake", "~> 10.0"
|
44
45
|
spec.add_development_dependency "rspec", "~> 3.0"
|
45
|
-
spec.add_development_dependency "activemodel", "~> 7.0"
|
46
46
|
end
|
@@ -16,7 +16,10 @@ module GraphitiGql
|
|
16
16
|
module ResourceExtras
|
17
17
|
extend ActiveSupport::Concern
|
18
18
|
|
19
|
-
|
19
|
+
prepended do
|
20
|
+
extend ActiveModel::Callbacks
|
21
|
+
define_model_callbacks :query
|
22
|
+
|
20
23
|
class << self
|
21
24
|
attr_accessor :graphql_name, :singular
|
22
25
|
end
|
@@ -57,7 +60,14 @@ module GraphitiGql
|
|
57
60
|
@selections
|
58
61
|
end
|
59
62
|
|
63
|
+
def around_scoping(original_scope, query_hash)
|
64
|
+
run_callbacks :query do
|
65
|
+
super { |scope| yield scope }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
60
69
|
class_methods do
|
70
|
+
|
61
71
|
def attribute(*args)
|
62
72
|
super(*args).tap do
|
63
73
|
opts = args.extract_options!
|
@@ -85,7 +95,7 @@ module GraphitiGql
|
|
85
95
|
end
|
86
96
|
end
|
87
97
|
end
|
88
|
-
Graphiti::Resource.send(:
|
98
|
+
Graphiti::Resource.send(:prepend, ResourceExtras)
|
89
99
|
|
90
100
|
module FilterExtras
|
91
101
|
def filter_param
|
@@ -269,7 +279,7 @@ module GraphitiGql
|
|
269
279
|
module ActiveRecordAdapterExtras
|
270
280
|
extend ActiveSupport::Concern
|
271
281
|
|
272
|
-
|
282
|
+
prepended do
|
273
283
|
alias_method :filter_precise_datetime_lt, :filter_lt
|
274
284
|
alias_method :filter_precise_datetime_lte, :filter_lte
|
275
285
|
alias_method :filter_precise_datetime_gt, :filter_gt
|
@@ -277,16 +287,59 @@ module GraphitiGql
|
|
277
287
|
alias_method :filter_precise_datetime_eq, :filter_eq
|
278
288
|
alias_method :filter_precise_datetime_not_eq, :filter_not_eq
|
279
289
|
end
|
290
|
+
|
291
|
+
# TODO: integration specs mysql vs postgres for case sensitivity
|
292
|
+
def mysql?(scope)
|
293
|
+
mysql = ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
294
|
+
scope.model.connection.is_a?(mysql)
|
295
|
+
end
|
296
|
+
|
297
|
+
def filter_string_eq(scope, attribute, value, is_not: false)
|
298
|
+
if mysql?(scope)
|
299
|
+
clause = { attribute => value }
|
300
|
+
is_not ? scope.where.not(clause) : scope.where(clause)
|
301
|
+
else
|
302
|
+
# og behavior
|
303
|
+
column = column_for(scope, attribute)
|
304
|
+
clause = column.lower.eq_any(value.map(&:downcase))
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
def filter_string_eql(scope, attribute, value, is_not: false)
|
309
|
+
if mysql?(scope)
|
310
|
+
value = "BINARY #{value}"
|
311
|
+
end
|
312
|
+
# og behavior
|
313
|
+
clause = {attribute => value}
|
314
|
+
is_not ? scope.where.not(clause) : scope.where(clause)
|
315
|
+
end
|
316
|
+
|
317
|
+
def sanitized_like_for(scope, attribute, value, &block)
|
318
|
+
escape_char = "\\"
|
319
|
+
column = column_for(scope, attribute)
|
320
|
+
map = value.map { |v|
|
321
|
+
v = v.downcase unless mysql?(scope)
|
322
|
+
v = Sanitizer.sanitize_like(v, escape_char)
|
323
|
+
block.call v
|
324
|
+
}
|
325
|
+
arel = column
|
326
|
+
arel = arel.lower unless mysql?(scope)
|
327
|
+
arel.matches_any(map, escape_char, true)
|
328
|
+
end
|
280
329
|
end
|
281
330
|
if defined?(Graphiti::Adapters::ActiveRecord)
|
282
|
-
Graphiti::Adapters::ActiveRecord.send(:
|
331
|
+
Graphiti::Adapters::ActiveRecord.send(:prepend, ActiveRecordAdapterExtras)
|
283
332
|
end
|
284
333
|
|
285
334
|
Graphiti::Adapters::Abstract.class_eval do
|
286
335
|
class << self
|
287
336
|
alias :old_default_operators :default_operators
|
288
337
|
def default_operators
|
289
|
-
old_default_operators.merge(
|
338
|
+
old_default_operators.merge({
|
339
|
+
precise_datetime: numerical_operators,
|
340
|
+
string_enum: [:eq, :not_eq],
|
341
|
+
integer_enum: [:eq, :not_eq],
|
342
|
+
})
|
290
343
|
end
|
291
344
|
end
|
292
345
|
end
|
data/lib/graphiti_gql/version.rb
CHANGED
data/lib/graphiti_gql.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.22
|
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-08-
|
11
|
+
date: 2022-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -52,6 +52,26 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.3.9
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activemodel
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '6.0'
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '8.0'
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '6.0'
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '8.0'
|
55
75
|
- !ruby/object:Gem::Dependency
|
56
76
|
name: bundler
|
57
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,20 +114,6 @@ dependencies:
|
|
94
114
|
- - "~>"
|
95
115
|
- !ruby/object:Gem::Version
|
96
116
|
version: '3.0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: activemodel
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '7.0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '7.0'
|
111
117
|
description:
|
112
118
|
email:
|
113
119
|
- richmolj@gmail.com
|
@@ -124,7 +130,6 @@ files:
|
|
124
130
|
- LICENSE.txt
|
125
131
|
- README.md
|
126
132
|
- Rakefile
|
127
|
-
- app/controllers/graphiti_gql/execution_controller.rb
|
128
133
|
- bin/bundle
|
129
134
|
- bin/byebug
|
130
135
|
- bin/coderay
|
@@ -136,7 +141,6 @@ files:
|
|
136
141
|
- bin/rake
|
137
142
|
- bin/rspec
|
138
143
|
- bin/setup
|
139
|
-
- config/routes.rb
|
140
144
|
- graphiti_gql.gemspec
|
141
145
|
- lib/graphiti_gql.rb
|
142
146
|
- lib/graphiti_gql/active_resource.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module GraphitiGql
|
2
|
-
class ExecutionController < GraphitiGql.config.application_controller
|
3
|
-
def execute
|
4
|
-
params = request.params # avoid strong_parameters
|
5
|
-
variables = params[:variables] || {}
|
6
|
-
result = GraphitiGql.run params[:query],
|
7
|
-
params[:variables],
|
8
|
-
graphql_context
|
9
|
-
render json: result
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def default_context
|
15
|
-
defined?(:current_user)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|