search_object_graphql 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +10 -2
- data/README.md +4 -4
- data/example/app/graphql/resolvers/category_search.rb +2 -2
- data/example/app/graphql/resolvers/post_search.rb +6 -6
- data/lib/search_object/plugin/graphql/version.rb +1 -1
- data/lib/search_object/plugin/graphql.rb +2 -0
- data/search_object_graphql.gemspec +1 -1
- data/spec/search_object/plugin/graphql_spec.rb +67 -9
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41da46a65689f3f9178a8e4848df69af6e03c97e8afb30560d33bafda1562b2b
|
4
|
+
data.tar.gz: 986e0d43576c42487751cfbc391caca2ec1cf694f6f16c9cb668d6d778570546
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f81ce9688f696bc17e0b4fbefdc7b8d2caa8defbebe637d5a45f980cc5ac40c9d065310414d1e96134fe0cc4a08b67a4b7cecfff04d01be293e93e8dccf5b43f
|
7
|
+
data.tar.gz: f0554a519c7248862329c7ce4a39667e167718e3daa5be221c8cbbac4293b35fc18c27a68f7adbb8b2994170207694130e9da8f41f0690680fab54bb9ac3c9e0
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6
|
1
|
+
2.7.6
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## Version 1.0.
|
3
|
+
## Version 1.0.4
|
4
|
+
|
5
|
+
* __[feature]__ Added `deprecation_reason` to `option` (@IgrekYY)
|
6
|
+
|
7
|
+
## Version 1.0.3
|
8
|
+
|
9
|
+
* __[fix]__ Support GraphQL 2.0 gem (@rstankov)
|
10
|
+
|
11
|
+
## Version 1.0.2
|
4
12
|
|
5
|
-
* __[feature]__ Added `argument_options` to `
|
13
|
+
* __[feature]__ Added `argument_options` to `option` (@wuz)
|
6
14
|
|
7
15
|
## Version 1.0.1
|
8
16
|
|
data/README.md
CHANGED
@@ -99,8 +99,8 @@ class PostResolver < GraphQL::Schema::Resolver
|
|
99
99
|
|
100
100
|
description 'Lists all posts'
|
101
101
|
|
102
|
-
option(:name, type:
|
103
|
-
option(:published, type:
|
102
|
+
option(:name, type: String, description: 'Fuzzy name matching') { ... }
|
103
|
+
option(:published, type: Boolean, description: 'Find published/unpublished') { ... }
|
104
104
|
end
|
105
105
|
```
|
106
106
|
|
@@ -112,7 +112,7 @@ class PostResolver < GraphQL::Schema::Resolver
|
|
112
112
|
|
113
113
|
scope { Post.all }
|
114
114
|
|
115
|
-
option(:published, type:
|
115
|
+
option(:published, type: Boolean, default: true) { |scope, value| value ? scope.published : scope.unpublished }
|
116
116
|
end
|
117
117
|
```
|
118
118
|
|
@@ -126,7 +126,7 @@ class PostResolver < GraphQL::Schema::Resolver
|
|
126
126
|
|
127
127
|
scope { Post.all }
|
128
128
|
|
129
|
-
option(:published, type:
|
129
|
+
option(:published, type: Boolean, argument_options: { pundit_role: :read }) { |scope, value| value ? scope.published : scope.unpublished }
|
130
130
|
end
|
131
131
|
```
|
132
132
|
|
@@ -14,8 +14,8 @@ module Resolvers
|
|
14
14
|
|
15
15
|
scope { Category.all }
|
16
16
|
|
17
|
-
option :id, type:
|
18
|
-
option :name, type:
|
17
|
+
option :id, type: String, with: :apply_id_filter
|
18
|
+
option :name, type: String, with: :apply_name_filter
|
19
19
|
option :order, type: OrderEnum, default: 'RECENT'
|
20
20
|
|
21
21
|
def apply_id_filter(scope, value)
|
@@ -16,12 +16,12 @@ module Resolvers
|
|
16
16
|
|
17
17
|
scope { object.respond_to?(:posts) ? object.posts : Post.all }
|
18
18
|
|
19
|
-
option :id, type:
|
20
|
-
option :title, type:
|
21
|
-
option :body, type:
|
22
|
-
option :categoryId, type:
|
23
|
-
option :categoryName, type:
|
24
|
-
option :published, type:
|
19
|
+
option :id, type: String, with: :apply_id_filter
|
20
|
+
option :title, type: String, with: :apply_title_filter
|
21
|
+
option :body, type: String, with: :apply_body_filter
|
22
|
+
option :categoryId, type: String, with: :apply_category_id_filter
|
23
|
+
option :categoryName, type: String, with: :apply_category_name_filter
|
24
|
+
option :published, type: Boolean, with: :apply_published_filter
|
25
25
|
option :order, type: OrderEnum, default: 'RECENT'
|
26
26
|
|
27
27
|
def apply_id_filter(scope, value)
|
@@ -37,6 +37,7 @@ module SearchObject
|
|
37
37
|
argument_options[:camelize] = options[:camelize] if options.include?(:camelize)
|
38
38
|
argument_options[:default_value] = options[:default] if options.include?(:default)
|
39
39
|
argument_options[:description] = options[:description] if options.include?(:description)
|
40
|
+
argument_options[:deprecation_reason] = options[:deprecation_reason] if options.include?(:deprecation_reason)
|
40
41
|
|
41
42
|
argument(name.to_s, type, **argument_options)
|
42
43
|
|
@@ -45,6 +46,7 @@ module SearchObject
|
|
45
46
|
super(name, options, &block)
|
46
47
|
end
|
47
48
|
|
49
|
+
# NOTE(rstankov): This is removed in GraphQL 2.0.0
|
48
50
|
def types
|
49
51
|
GraphQL::Define::TypeDefiner.instance
|
50
52
|
end
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.add_dependency 'graphql', '
|
23
|
+
spec.add_dependency 'graphql', '> 1.8'
|
24
24
|
spec.add_dependency 'search_object', '~> 1.2.2'
|
25
25
|
|
26
26
|
spec.add_development_dependency 'coveralls'
|
@@ -92,7 +92,7 @@ describe SearchObject::Plugin::Graphql do
|
|
92
92
|
|
93
93
|
type [post_type], null: 1
|
94
94
|
|
95
|
-
option(:id, type:
|
95
|
+
option(:id, type: GraphQL::Types::ID) { |scope, value| scope.select { |p| p.id == value } }
|
96
96
|
end
|
97
97
|
|
98
98
|
schema = define_schema do
|
@@ -225,7 +225,7 @@ describe SearchObject::Plugin::Graphql do
|
|
225
225
|
|
226
226
|
it 'accepts default type' do
|
227
227
|
schema = define_search_class_and_return_schema do
|
228
|
-
option(:id, type:
|
228
|
+
option(:id, type: String, default: 'default') do |_scope, value|
|
229
229
|
[Post.new(value)]
|
230
230
|
end
|
231
231
|
end
|
@@ -243,7 +243,7 @@ describe SearchObject::Plugin::Graphql do
|
|
243
243
|
schema = define_search_class_and_return_schema do
|
244
244
|
type PostType, null: true
|
245
245
|
|
246
|
-
option('option', type:
|
246
|
+
option('option', type: String, default: 'default') { [] }
|
247
247
|
end
|
248
248
|
|
249
249
|
result = schema.execute <<~GRAPHQL
|
@@ -277,7 +277,7 @@ describe SearchObject::Plugin::Graphql do
|
|
277
277
|
|
278
278
|
it 'accepts "required"' do
|
279
279
|
schema = define_search_class_and_return_schema do
|
280
|
-
option(:id, type:
|
280
|
+
option(:id, type: String, required: true) do |_scope, value|
|
281
281
|
[Post.new(value)]
|
282
282
|
end
|
283
283
|
end
|
@@ -292,7 +292,7 @@ describe SearchObject::Plugin::Graphql do
|
|
292
292
|
permission: true
|
293
293
|
}
|
294
294
|
schema = define_search_class_and_return_schema do
|
295
|
-
option(:id, type:
|
295
|
+
option(:id, type: String, argument_options: argument_options) do |_scope, value|
|
296
296
|
[Post.new(value)]
|
297
297
|
end
|
298
298
|
end
|
@@ -304,14 +304,13 @@ describe SearchObject::Plugin::Graphql do
|
|
304
304
|
'posts' => [Post.new('2').to_json]
|
305
305
|
}
|
306
306
|
)
|
307
|
-
|
308
307
|
end
|
309
308
|
|
310
309
|
it 'accepts description' do
|
311
310
|
schema = define_search_class_and_return_schema do
|
312
311
|
type PostType, null: true
|
313
312
|
|
314
|
-
option('option', type:
|
313
|
+
option('option', type: String, description: 'what this argument does') { [] }
|
315
314
|
end
|
316
315
|
|
317
316
|
result = schema.execute <<-SQL
|
@@ -347,7 +346,7 @@ describe SearchObject::Plugin::Graphql do
|
|
347
346
|
schema = define_search_class_and_return_schema do
|
348
347
|
type PostType, null: true
|
349
348
|
|
350
|
-
option('option_field', type:
|
349
|
+
option('option_field', type: String, camelize: false)
|
351
350
|
end
|
352
351
|
|
353
352
|
result = schema.execute <<-SQL
|
@@ -381,7 +380,7 @@ describe SearchObject::Plugin::Graphql do
|
|
381
380
|
schema = define_search_class_and_return_schema do
|
382
381
|
type PostType, null: true
|
383
382
|
|
384
|
-
option('option_field', type:
|
383
|
+
option('option_field', type: String)
|
385
384
|
end
|
386
385
|
|
387
386
|
result = schema.execute <<~GRAPHQL
|
@@ -411,6 +410,65 @@ describe SearchObject::Plugin::Graphql do
|
|
411
410
|
)
|
412
411
|
end
|
413
412
|
|
413
|
+
it 'accepts deprecation_reason' do
|
414
|
+
schema = define_search_class_and_return_schema do
|
415
|
+
type PostType, null: true
|
416
|
+
|
417
|
+
option('option', type: String, deprecation_reason: 'Not in use anymore')
|
418
|
+
end
|
419
|
+
|
420
|
+
|
421
|
+
result = schema.execute <<-SQL
|
422
|
+
{
|
423
|
+
__type(name: "Query") {
|
424
|
+
name
|
425
|
+
fields {
|
426
|
+
args(includeDeprecated: false) {
|
427
|
+
name
|
428
|
+
}
|
429
|
+
}
|
430
|
+
}
|
431
|
+
}
|
432
|
+
SQL
|
433
|
+
|
434
|
+
expect(result.to_h).to eq(
|
435
|
+
'data' => {
|
436
|
+
'__type' => {
|
437
|
+
'name' => 'Query',
|
438
|
+
'fields' => [{
|
439
|
+
'args' => []
|
440
|
+
}]
|
441
|
+
}
|
442
|
+
}
|
443
|
+
)
|
444
|
+
|
445
|
+
result = schema.execute <<-SQL
|
446
|
+
{
|
447
|
+
__type(name: "Query") {
|
448
|
+
name
|
449
|
+
fields {
|
450
|
+
args(includeDeprecated: true) {
|
451
|
+
name
|
452
|
+
}
|
453
|
+
}
|
454
|
+
}
|
455
|
+
}
|
456
|
+
SQL
|
457
|
+
|
458
|
+
expect(result.to_h).to eq(
|
459
|
+
'data' => {
|
460
|
+
'__type' => {
|
461
|
+
'name' => 'Query',
|
462
|
+
'fields' => [{
|
463
|
+
'args' => [{
|
464
|
+
'name' => 'option',
|
465
|
+
}]
|
466
|
+
}]
|
467
|
+
}
|
468
|
+
}
|
469
|
+
)
|
470
|
+
end
|
471
|
+
|
414
472
|
it 'raises error when no type is given' do
|
415
473
|
expect { define_search_class { option :name } }.to raise_error described_class::MissingTypeDefinitionError
|
416
474
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radoslav Stankov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -192,7 +192,7 @@ homepage: https://github.com/RStankov/SearchObjectGraphQL
|
|
192
192
|
licenses:
|
193
193
|
- MIT
|
194
194
|
metadata: {}
|
195
|
-
post_install_message:
|
195
|
+
post_install_message:
|
196
196
|
rdoc_options: []
|
197
197
|
require_paths:
|
198
198
|
- lib
|
@@ -207,8 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
211
|
-
signing_key:
|
210
|
+
rubygems_version: 3.1.6
|
211
|
+
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: Maps search objects to GraphQL resolvers
|
214
214
|
test_files:
|