search_object_graphql 1.0.0 → 1.0.1

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: 49fd6817f69aa33a15ce7cc2e768bd239020c3f7f6b6e385e1f12d3c9d5c30ff
4
- data.tar.gz: c6c4a8d82f1d5afa85519a1e8aee726b321495b2305e63fa0d5e986db75066fb
3
+ metadata.gz: c82b2028e4c0234e7f8109dbe66cb37746efc7c39e17d7e31a02b10f3e975c5e
4
+ data.tar.gz: b9d2f3bb799b65943fbcd3d777a75e9a1c3348dd7a33b0064212e373f6bd7422
5
5
  SHA512:
6
- metadata.gz: a71588bac7cc2fba645d1e4007bfeed111749c0016d4a2de7e832990ff33f37e1656c08a47fd3a52f18664e594bbefee3939d1412aa3fc5d679dd9c3d875d533
7
- data.tar.gz: 4c9bfd49332eafbd37b10be48bc58c65bfffa0546dc7c394a7b77e3e146769ee77083f39bbd40f101302ad7ffb967d8b7e0054b6512c35febdcedc0e00c94855
6
+ metadata.gz: a321cd52dfab7394ab746afa2b4d288be0a1beeec9eaa4286989fd0d63a4427f3153aa8aec2ebc42431daea0513b2604d6e123512a22e1cd394ef00ed330dc1c
7
+ data.tar.gz: 0e6a7c3a3a8a3695b4b2797aa0bcb26c5b98d3bd0bc8d91a605d2e26bafe6c58d001eb260d81fcc88d53c0f3b28f945bd6387ce3860bcd48412f781e38c4be1f
data/.rubocop.yml CHANGED
@@ -49,3 +49,9 @@ RSpec/ExampleLength:
49
49
  # Disables "Too many expectations."
50
50
  RSpec/MultipleExpectations:
51
51
  Enabled: false
52
+
53
+ Metrics/CyclomaticComplexity:
54
+ Enabled: false
55
+
56
+ Metrics/PerceivedComplexity:
57
+ Enabled: false
data/.travis.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.1
4
3
  - 2.5.2
5
4
  - 2.6.0
5
+ - 2.7.1
6
+ - 3.0.0
6
7
  script:
7
8
  - bundle exec rubocop
8
9
  - bundle exec rspec spec
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## Version 1.0.0 (unreleased)
3
+ ## Version 1.0.1
4
+
5
+ * __[fix]__ `camelize` defaults to false when not specified (@haines)
6
+
7
+ ## Version 1.0.0
4
8
 
5
9
  * __[break]__ Removed support for defining types via `type` method (@rstankov)
6
10
  * __[break]__ Require `GraphQL::Schema::Resolver` inheritance (@rstankov)
@@ -29,15 +29,15 @@ module SearchObject
29
29
  module ClassMethods
30
30
  def option(name, options = {}, &block)
31
31
  type = options.fetch(:type) { raise MissingTypeDefinitionError, name }
32
- options[:enum] = type.values.map { |value, enum_value| enum_value.value || value } if type.respond_to?(:values)
33
32
 
34
- argument(
35
- name.to_s,
36
- options[:type],
37
- required: options[:required] || false,
38
- description: options[:description],
39
- camelize: options[:camelize]
40
- )
33
+ argument_options = { required: options[:required] || false }
34
+ argument_options[:camelize] = options[:camelize] if options.include?(:camelize)
35
+ argument_options[:default_value] = options[:default] if options.include?(:default)
36
+ argument_options[:description] = options[:description] if options.include?(:description)
37
+
38
+ argument(name.to_s, type, **argument_options)
39
+
40
+ options[:enum] = type.values.map { |value, enum_value| enum_value.value || value } if type.respond_to?(:values)
41
41
 
42
42
  super(name, options, &block)
43
43
  end
@@ -3,7 +3,7 @@
3
3
  module SearchObject
4
4
  module Plugin
5
5
  module Graphql
6
- VERSION = '1.0.0'
6
+ VERSION = '1.0.1'
7
7
  end
8
8
  end
9
9
  end
@@ -217,6 +217,42 @@ describe SearchObject::Plugin::Graphql do
217
217
  )
218
218
  end
219
219
 
220
+ it 'sets default_value on the argument' do
221
+ schema = define_search_class_and_return_schema do
222
+ type PostType, null: true
223
+
224
+ option('option', type: types.String, default: 'default') { [] }
225
+ end
226
+
227
+ result = schema.execute <<~GRAPHQL
228
+ {
229
+ __type(name: "Query") {
230
+ name
231
+ fields {
232
+ args {
233
+ name
234
+ defaultValue
235
+ }
236
+ }
237
+ }
238
+ }
239
+ GRAPHQL
240
+
241
+ expect(result).to eq(
242
+ 'data' => {
243
+ '__type' => {
244
+ 'name' => 'Query',
245
+ 'fields' => [{
246
+ 'args' => [{
247
+ 'name' => 'option',
248
+ 'defaultValue' => '"default"'
249
+ }]
250
+ }]
251
+ }
252
+ }
253
+ )
254
+ end
255
+
220
256
  it 'accepts "required"' do
221
257
  schema = define_search_class_and_return_schema do
222
258
  option(:id, type: types.String, required: true) do |_scope, value|
@@ -299,6 +335,40 @@ describe SearchObject::Plugin::Graphql do
299
335
  )
300
336
  end
301
337
 
338
+ it 'does not override the default camelize option' do
339
+ schema = define_search_class_and_return_schema do
340
+ type PostType, null: true
341
+
342
+ option('option_field', type: types.String)
343
+ end
344
+
345
+ result = schema.execute <<~GRAPHQL
346
+ {
347
+ __type(name: "Query") {
348
+ name
349
+ fields {
350
+ args {
351
+ name
352
+ }
353
+ }
354
+ }
355
+ }
356
+ GRAPHQL
357
+
358
+ expect(result.to_h).to eq(
359
+ 'data' => {
360
+ '__type' => {
361
+ 'name' => 'Query',
362
+ 'fields' => [{
363
+ 'args' => [{
364
+ 'name' => 'optionField'
365
+ }]
366
+ }]
367
+ }
368
+ }
369
+ )
370
+ end
371
+
302
372
  it 'raises error when no type is given' do
303
373
  expect { define_search_class { option :name } }.to raise_error described_class::MissingTypeDefinitionError
304
374
  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: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radoslav Stankov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-14 00:00:00.000000000 Z
11
+ date: 2021-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql