search_object_graphql 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- 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 +1 -0
- data/search_object_graphql.gemspec +1 -1
- data/spec/search_object/plugin/graphql_spec.rb +8 -9
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4743546d8933b7412977b5b2736eca71fd8950ef016ca5e4f766a73e7f75d0dd
|
4
|
+
data.tar.gz: a9772b5cb3cfda0e8cbc334a68d24d919b964e81af00be8696a91b3bc0d60947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c1400ac1875e40b26a1ef4c8e5180e2324cc5e671b715e61172f5dd51cce443fce19dfaa92d5783791a3d8cc06de9c6d1a238b2f9e9c3158aab35cee21c58d6
|
7
|
+
data.tar.gz: ff5bd7c05cc45cd815a8682423dee031ea720d7c3da766a8aa19e9df1d52d9013592ed4bf58255c218ab9dc0e8c1c0c2a6fd95c91e7961f04f346fe0f3a2bf1f
|
data/CHANGELOG.md
CHANGED
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)
|
@@ -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
|
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.3
|
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: 2022-03-18 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
|