graphql-filters 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: 69e8dec5946ab6eef47034012795f666d1714a4d67e5cee5ecaa105fd4a33e47
4
- data.tar.gz: 52eaaf103d30162c293e6dd71df104455ae6adea20832f5acb1495379e084ab7
3
+ metadata.gz: 1ea0487a315eba7379064803399873439f3c0f8d4f4834a036018d393b85338a
4
+ data.tar.gz: 0c304de0494022456ea6cd65b893390c0b57ea6033852c8b676af92d7d5f1ad2
5
5
  SHA512:
6
- metadata.gz: cf5c8e6bd9fa9d30140affe06cb1f5e7cad8f04787a131d42419a28b4ed5a43cb13cd18179c7da3e07645e4cb043cc240f326d0066d8390ff3ca01f4be12c1f3
7
- data.tar.gz: 8e0b3de41937ffd98350dec8409fd8757d20d46e4f8f917ffb24ceb0856fa0450736c838a91e3d6333bb152e1d99cd478862a95899a3145ad7c70e089a50b595
6
+ metadata.gz: 77cdc50f80b142628f1b66ba80ac6db8c5d9f86f477f5ec9ebff3ede53b0ad3bba58cb850774c7f9573e964a172aef35f532dc3880efa73631fed897222dd6ce
7
+ data.tar.gz: bed2892de9d4ce4c7c5a3e0c5c121624eac2a56d1870e879b45048af57e07a36acc34771936056e806baf629b2b4132149e059ab427d9c70931cd52ecbaaa4a7
data/CHANGELOG.md CHANGED
@@ -8,6 +8,13 @@
8
8
  ### Bug fixes
9
9
  )
10
10
 
11
+ ## 1.0.1 2023-03-15
12
+
13
+ ### Bug fixes
14
+
15
+ - Fixed the priority of options declarations for fields
16
+ - Fixed the override of `method_name` for the column name to use in the Active Record query
17
+
11
18
  ## 1.0.0 2023-03-06
12
19
 
13
20
  First release. Refer to [README.md](README.md) for the full documentation.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql-filters (1.0.0)
4
+ graphql-filters (1.0.1)
5
5
  activerecord (~> 7.0.0)
6
6
  activesupport (~> 7.0.0)
7
7
  graphql (~> 2.0.0)
data/README.md CHANGED
@@ -9,7 +9,7 @@ This gem provides a module to include (or prepend, see below) in your resolvers
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'graphql-filters', '~> 0.1.0'
12
+ gem 'graphql-filters', '~> 1.0'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -24,7 +24,7 @@ The easiest way to use GraphQL Filters is on top of [SearchObject](https://githu
24
24
  ```ruby
25
25
  class RoutesResolver < BaseResolver
26
26
  include SearchObject.module(:graphql)
27
-
27
+
28
28
  scope { Route.all }
29
29
 
30
30
  type [RouteType], null: false
@@ -33,12 +33,12 @@ class RoutesResolver < BaseResolver
33
33
  end
34
34
  ```
35
35
 
36
- Otherwise, you have to explicitly define a `resolve` method and have it return an `ActiveRecord::Relation`; in this case youy need to prepend `GraphQL::Filters::Filterable` in the resolver, otherwise it won't have access to the starting scope:
36
+ Otherwise, you have to explicitly define a `resolve` method and have it return an `ActiveRecord::Relation`; in this case you need to prepend `GraphQL::Filters::Filterable` in the resolver, otherwise it won't have access to the starting scope:
37
37
 
38
38
  ```ruby
39
39
  class RoutesResolver < BaseResolver
40
40
  type [RouteType], null: false
41
-
41
+
42
42
  def resolve
43
43
  Route.all
44
44
  end
@@ -217,7 +217,7 @@ end
217
217
  Can be `true` or `false` (default: `true`). Controls whether or not the client can use this field in the filters. Passing `true` or `false` directly to `filter` is a shortcut:
218
218
 
219
219
  ```ruby
220
- field :name, String, null: false, filter: false
220
+ field :name, String, null: false, filter: false
221
221
 
222
222
  # is equivalent to
223
223
 
@@ -229,7 +229,7 @@ field :name, String, null: false, filter: {enabled: false}
229
229
  The name of the attribute that the field is tied to in the model. Defaults to the name of the resolver method for the field (which by default is the same as the name of the field itself).
230
230
 
231
231
  - `association_name`
232
-
232
+
233
233
  The name of the Active Record association that the field is tied to in the model. Equivalent to `attribute_name`, has the same default.
234
234
 
235
235
  ## Plans for future development
@@ -43,21 +43,18 @@ monkey_patch = Module.new do
43
43
  options
44
44
  end
45
45
 
46
- applied_filter_options_defaults = filter_options_defaults.transform_values do |value|
46
+ filter_options.merge! options
47
+ filter_options.merge! kwargs
48
+ end
49
+
50
+ def filter_options
51
+ @filter_options ||= filter_options_defaults.transform_values do |value|
47
52
  if value.is_a? Proc
48
53
  value.call self
49
54
  else
50
55
  value
51
56
  end
52
57
  end
53
-
54
- filter_options.reverse_merge! applied_filter_options_defaults
55
- filter_options.reverse_merge! options
56
- filter_options.reverse_merge! kwargs
57
- end
58
-
59
- def filter_options
60
- @filter_options ||= {}
61
58
  end
62
59
  end
63
60
 
@@ -21,7 +21,7 @@ module GraphQL
21
21
  required: false,
22
22
  prepare: lambda { |field_comparator, _context|
23
23
  lambda { |scope|
24
- if scope.klass.attribute_names.include? filter_options[:attribute_name]
24
+ if scope.klass.attribute_names.include? filter_options[:attribute_name].to_s
25
25
  field_comparator.call scope, filter_options[:attribute_name]
26
26
  else
27
27
  field_comparator.call scope, filter_options[:association_name]
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Filters
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-filters
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
  - Moku S.r.l.
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-03-06 00:00:00.000000000 Z
12
+ date: 2023-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord