search_object_graphql 0.3.1 → 0.3.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ab34781a81c8808d0b9702dcf9742955e9859c5827461e00e1b1a431f1df216
|
4
|
+
data.tar.gz: b5ed30f8e4b39c36d4fb1e9d28b1f2118a7bfd1507a045fac76286a61e8345ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93701d2abfb6a521f6aa199aaaf4a0fee641367a20de4b2806cbaeac45539909289529183590ca924c7329aeb7ce9cf53d3c5b581205208338c0ef8200e97874
|
7
|
+
data.tar.gz: 209b6af6cea55e752c7c76cbdb9769e8af18bed61c124982e58e502f7e10d8136f3a29653875c7b25d876676db0bdb3cb9faa0605132dfca3356a614288255ee
|
data/CHANGELOG.md
CHANGED
@@ -26,7 +26,7 @@ module SearchObject
|
|
26
26
|
end
|
27
27
|
|
28
28
|
module ClassMethods
|
29
|
-
KEYS = %i[type default description required].freeze
|
29
|
+
KEYS = %i[type default description required camelize].freeze
|
30
30
|
def option(name, options = {}, &block)
|
31
31
|
config[:arguments] ||= {}
|
32
32
|
config[:arguments][name.to_s] = KEYS.inject({}) do |acc, key|
|
@@ -100,14 +100,17 @@ module SearchObject
|
|
100
100
|
resolver_class: self,
|
101
101
|
deprecation_reason: deprecation_reason,
|
102
102
|
arguments: (config[:arguments] || {}).inject({}) do |acc, (name, options)|
|
103
|
-
|
104
|
-
|
103
|
+
if options.fetch(:camelize) { true }
|
104
|
+
name = name.to_s.split('_').map(&:capitalize).join
|
105
|
+
name[0] = name[0].downcase
|
106
|
+
end
|
105
107
|
|
106
108
|
acc[name] = ::GraphQL::Schema::Argument.new(
|
107
109
|
name: name.to_s,
|
108
110
|
type: options.fetch(:type) { raise MissingTypeDefinitionError, name },
|
109
111
|
description: options[:description],
|
110
112
|
required: !!options[:required],
|
113
|
+
camelize: !!options[:camelize],
|
111
114
|
default_value: options.fetch(:default) { ::GraphQL::Schema::Argument::NO_DEFAULT },
|
112
115
|
owner: self
|
113
116
|
)
|
@@ -362,6 +362,40 @@ describe SearchObject::Plugin::Graphql do
|
|
362
362
|
)
|
363
363
|
end
|
364
364
|
|
365
|
+
it 'accepts camelize' do
|
366
|
+
schema = define_search_class_and_return_schema do
|
367
|
+
type PostType
|
368
|
+
|
369
|
+
option('option_field', type: types.String, camelize: false)
|
370
|
+
end
|
371
|
+
|
372
|
+
result = schema.execute <<-SQL
|
373
|
+
{
|
374
|
+
__type(name: "Query") {
|
375
|
+
name
|
376
|
+
fields {
|
377
|
+
args {
|
378
|
+
name
|
379
|
+
}
|
380
|
+
}
|
381
|
+
}
|
382
|
+
}
|
383
|
+
SQL
|
384
|
+
|
385
|
+
expect(result.to_h).to eq(
|
386
|
+
'data' => {
|
387
|
+
'__type' => {
|
388
|
+
'name' => 'Query',
|
389
|
+
'fields' => [{
|
390
|
+
'args' => [{
|
391
|
+
'name' => 'option_field'
|
392
|
+
}]
|
393
|
+
}]
|
394
|
+
}
|
395
|
+
}
|
396
|
+
)
|
397
|
+
end
|
398
|
+
|
365
399
|
it 'raises error when no type is given' do
|
366
400
|
expect { define_search_class { option :name } }.to raise_error described_class::MissingTypeDefinitionError
|
367
401
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: search_object_graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radoslav Stankov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|