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 +4 -4
- data/.rubocop.yml +6 -0
- data/.travis.yml +2 -1
- data/CHANGELOG.md +5 -1
- data/lib/search_object/plugin/graphql.rb +8 -8
- data/lib/search_object/plugin/graphql/version.rb +1 -1
- data/spec/search_object/plugin/graphql_spec.rb +70 -0
- 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: c82b2028e4c0234e7f8109dbe66cb37746efc7c39e17d7e31a02b10f3e975c5e
|
4
|
+
data.tar.gz: b9d2f3bb799b65943fbcd3d777a75e9a1c3348dd7a33b0064212e373f6bd7422
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a321cd52dfab7394ab746afa2b4d288be0a1beeec9eaa4286989fd0d63a4427f3153aa8aec2ebc42431daea0513b2604d6e123512a22e1cd394ef00ed330dc1c
|
7
|
+
data.tar.gz: 0e6a7c3a3a8a3695b4b2797aa0bcb26c5b98d3bd0bc8d91a605d2e26bafe6c58d001eb260d81fcc88d53c0f3b28f945bd6387ce3860bcd48412f781e38c4be1f
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## Version 1.0.
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
@@ -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.
|
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-
|
11
|
+
date: 2021-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|