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: b313f4a7e0d42b0031ef92926b593961b3f6bd1210819199cf8ed4c3cd0f2f52
4
- data.tar.gz: dfeac9c067eff2bd9a8442e27d414761aa4c3947d6aa22c7765219a87afd4d2a
3
+ metadata.gz: 2ab34781a81c8808d0b9702dcf9742955e9859c5827461e00e1b1a431f1df216
4
+ data.tar.gz: b5ed30f8e4b39c36d4fb1e9d28b1f2118a7bfd1507a045fac76286a61e8345ac
5
5
  SHA512:
6
- metadata.gz: 2f61fb7c1878d1a648fae5a0a7e629d1509e63755d36705821c5a2e820347fe4ebf7a2e33ce7e87f8d12a20e81701e69b4baafbcab842a7ae3f8625b6d861a8f
7
- data.tar.gz: 3adcb65a0767ed0d7458e099a0e594bcb7a08d6bae0592f75fefa0a09060d2a0dbb9bdf54e1ce7f00cb998882375bfe7dc83f5c4dfcb95b64e4c7607fd510dbd
6
+ metadata.gz: 93701d2abfb6a521f6aa199aaaf4a0fee641367a20de4b2806cbaeac45539909289529183590ca924c7329aeb7ce9cf53d3c5b581205208338c0ef8200e97874
7
+ data.tar.gz: 209b6af6cea55e752c7c76cbdb9769e8af18bed61c124982e58e502f7e10d8136f3a29653875c7b25d876676db0bdb3cb9faa0605132dfca3356a614288255ee
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.3.2
4
+
5
+ * __[feature]__ Added `camelize` argument to `option`, *`true` by default* (@glenbray)
6
+
3
7
  ## Version 0.3.1
4
8
 
5
9
  * __[fix]__ Support for GraphQL gem version v1.9.16 (@ardinusawan)
@@ -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
- name = name.to_s.split('_').map(&:capitalize).join
104
- name[0] = name[0].downcase
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
  )
@@ -3,7 +3,7 @@
3
3
  module SearchObject
4
4
  module Plugin
5
5
  module Graphql
6
- VERSION = '0.3.1'
6
+ VERSION = '0.3.2'
7
7
  end
8
8
  end
9
9
  end
@@ -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.1
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: 2019-12-05 00:00:00.000000000 Z
11
+ date: 2020-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql