graphql-pagination 2.0.0 → 2.1.0

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: 66ee4e073251b59ae351cabd16e4122d2b9aca8ad2bf666b6a7d7f24004d2d60
4
- data.tar.gz: ca7ab1e6a8612d16a80296b50158073e42d160dc4ef9487d6926968153847e93
3
+ metadata.gz: ba2564755b00967af752c896752143dae2de5519edc1b3b4528ff653b1a30ef1
4
+ data.tar.gz: 469bb8190f417420ca82535b854b1dff1c039dea9a0fa5998f3f85df83ae7776
5
5
  SHA512:
6
- metadata.gz: f281e3304279f6f02dfde1c682a94ad3fe2771c41052ab97982200a17257b9a2650ab858fc70834bcef0a0651b61e34190765fcc121c0c4c71a8adb93e072a1f
7
- data.tar.gz: ddd6dd8edb076763cb918abb30187bd67d6b62999f89eb08abd39b5324794a0fcbafb1ca4c16f95809e14959941c5720d8eaedc7036d83f4cf1ca9d4047f59ff
6
+ metadata.gz: 9517c649c9e976eee72e1144bed30c9bc7f4e5a0eae51822e063605d0a110a66d0706b156b0122a51abb81efa5cd548607de594624453ea9b0addf8e34876757
7
+ data.tar.gz: 5a3ef06d7912a19bc8c5382873898af974e5bc1f23a130d9cee04a70be2fdb84e58499954057d7ac58bc6d6e3a0ab09eb48311cd2e7d9cf63977dd763e6663dc
data/.bundler-version CHANGED
@@ -1 +1 @@
1
- 2.3.10
1
+ 2.3.22
@@ -14,12 +14,9 @@ jobs:
14
14
  ruby-version: ['3.0', 3.1]
15
15
 
16
16
  steps:
17
- - uses: actions/checkout@v2
17
+ - uses: actions/checkout@v3
18
18
  - name: Set up Ruby
19
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
20
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
21
- # uses: ruby/setup-ruby@v1
22
- uses: ruby/setup-ruby@bd94d6a504586da892a5753afdd1480096ed30df
19
+ uses: ruby/setup-ruby@v1
23
20
  with:
24
21
  ruby-version: ${{ matrix.ruby-version }}
25
22
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
data/Gemfile.lock CHANGED
@@ -1,18 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql-pagination (2.0.0)
4
+ graphql-pagination (2.1.0)
5
5
  graphql (~> 2.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (7.0.2.3)
11
- activesupport (= 7.0.2.3)
12
- activerecord (7.0.2.3)
13
- activemodel (= 7.0.2.3)
14
- activesupport (= 7.0.2.3)
15
- activesupport (7.0.2.3)
10
+ activemodel (7.0.4)
11
+ activesupport (= 7.0.4)
12
+ activerecord (7.0.4)
13
+ activemodel (= 7.0.4)
14
+ activesupport (= 7.0.4)
15
+ activesupport (7.0.4)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 1.6, < 2)
18
18
  minitest (>= 5.1)
@@ -21,24 +21,25 @@ GEM
21
21
  coderay (1.1.3)
22
22
  concurrent-ruby (1.1.10)
23
23
  diff-lcs (1.5.0)
24
- graphql (2.0.5)
25
- i18n (1.10.0)
24
+ graphql (2.0.14)
25
+ i18n (1.12.0)
26
26
  concurrent-ruby (~> 1.0)
27
+ json (2.6.2)
27
28
  kaminari-activerecord (1.2.2)
28
29
  activerecord
29
30
  kaminari-core (= 1.2.2)
30
31
  kaminari-core (1.2.2)
31
32
  method_source (1.0.0)
32
- minitest (5.15.0)
33
+ minitest (5.16.3)
33
34
  parallel (1.22.1)
34
- parser (3.1.1.0)
35
+ parser (3.1.2.1)
35
36
  ast (~> 2.4.1)
36
37
  pry (0.14.1)
37
38
  coderay (~> 1.1)
38
39
  method_source (~> 1.0)
39
40
  rainbow (3.1.1)
40
41
  rake (13.0.6)
41
- regexp_parser (2.2.1)
42
+ regexp_parser (2.6.0)
42
43
  rexml (3.2.5)
43
44
  rspec (3.11.0)
44
45
  rspec-core (~> 3.11.0)
@@ -46,35 +47,37 @@ GEM
46
47
  rspec-mocks (~> 3.11.0)
47
48
  rspec-core (3.11.0)
48
49
  rspec-support (~> 3.11.0)
49
- rspec-expectations (3.11.0)
50
+ rspec-expectations (3.11.1)
50
51
  diff-lcs (>= 1.2.0, < 2.0)
51
52
  rspec-support (~> 3.11.0)
52
53
  rspec-mocks (3.11.1)
53
54
  diff-lcs (>= 1.2.0, < 2.0)
54
55
  rspec-support (~> 3.11.0)
55
- rspec-support (3.11.0)
56
- rubocop (1.26.1)
56
+ rspec-support (3.11.1)
57
+ rubocop (1.36.0)
58
+ json (~> 2.3)
57
59
  parallel (~> 1.10)
58
- parser (>= 3.1.0.0)
60
+ parser (>= 3.1.2.1)
59
61
  rainbow (>= 2.2.2, < 4.0)
60
62
  regexp_parser (>= 1.8, < 3.0)
61
- rexml
62
- rubocop-ast (>= 1.16.0, < 2.0)
63
+ rexml (>= 3.2.5, < 4.0)
64
+ rubocop-ast (>= 1.20.1, < 2.0)
63
65
  ruby-progressbar (~> 1.7)
64
66
  unicode-display_width (>= 1.4.0, < 3.0)
65
- rubocop-ast (1.16.0)
67
+ rubocop-ast (1.21.0)
66
68
  parser (>= 3.1.1.0)
67
69
  rubocop-rake (0.6.0)
68
70
  rubocop (~> 1.0)
69
- rubocop-rspec (2.9.0)
70
- rubocop (~> 1.19)
71
+ rubocop-rspec (2.13.2)
72
+ rubocop (~> 1.33)
71
73
  ruby-progressbar (1.11.0)
72
- tzinfo (2.0.4)
74
+ tzinfo (2.0.5)
73
75
  concurrent-ruby (~> 1.0)
74
- unicode-display_width (2.1.0)
76
+ unicode-display_width (2.3.0)
75
77
 
76
78
  PLATFORMS
77
79
  aarch64-linux-musl
80
+ ruby
78
81
  x86_64-darwin-18
79
82
  x86_64-darwin-19
80
83
  x86_64-darwin-20
@@ -93,4 +96,4 @@ DEPENDENCIES
93
96
  rubocop-rspec
94
97
 
95
98
  BUNDLED WITH
96
- 2.3.10
99
+ 2.3.24
data/README.md CHANGED
@@ -73,6 +73,25 @@ Value returned by query resolver must be a kaminari object or implements its pag
73
73
  }
74
74
  ```
75
75
 
76
+ ## Custom Base
77
+
78
+ By default the resulting collection_type class is a direct descendant of
79
+ graphql-ruby's GraphQL::Schema::Object, however you may require your own
80
+ behaviours and properties on the collection class itself such as defining
81
+ [custom visibility](https://graphql-ruby.org/authorization/visibility.html#object-visibility).
82
+
83
+ This can be done by passing in your own custom class, to be inherited from:
84
+
85
+ ```ruby
86
+ class MyBaseType < GraphQL::Schema::Object
87
+ def self.visible?(context)
88
+ # ...
89
+ end
90
+ end
91
+
92
+ field :fruits, Types::FruitType.collection_type(collection_base: MyBaseType)
93
+ ```
94
+
76
95
  ## Custom Metadata
77
96
 
78
97
  By default, the following fields are present in the metadata block:
data/Rakefile CHANGED
@@ -6,4 +6,4 @@ RSpec::Core::RakeTask.new(:spec)
6
6
  RuboCop::RakeTask.new
7
7
 
8
8
  task ci: %i[spec rubocop]
9
- task default: %i[spec rubocop:auto_correct]
9
+ task default: %i[spec rubocop:autocorrect_all]
@@ -0,0 +1,8 @@
1
+ module GraphqlPagination
2
+ class CollectionBaseError < StandardError
3
+ def message
4
+ "CollectionBaseError: The collection_type attribute must inherit from
5
+ or be a GraphQL::Schema::Object"
6
+ end
7
+ end
8
+ end
@@ -1,12 +1,18 @@
1
1
  module GraphqlPagination
2
2
  module CollectionType
3
- def collection_type(metadata_type: GraphqlPagination::CollectionMetadataType)
3
+ def collection_type(
4
+ collection_base: GraphQL::Schema::Object,
5
+ metadata_type: GraphqlPagination::CollectionMetadataType
6
+ )
7
+ fail CollectionBaseError unless collection_base <= GraphQL::Schema::Object
8
+
4
9
  @collection_types ||= {}
5
- @collection_types[metadata_type] ||= begin
10
+ @collection_types[collection_base] ||= {}
11
+ @collection_types[collection_base][metadata_type] ||= begin
6
12
  type_name = "#{graphql_name}Collection"
7
13
  source_type = self
8
14
 
9
- Class.new(GraphQL::Schema::Object) do
15
+ Class.new(collection_base) do
10
16
  graphql_name type_name
11
17
  field :collection, [source_type], null: false
12
18
  field :metadata, metadata_type, null: false
@@ -1,3 +1,3 @@
1
1
  module GraphqlPagination
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
@@ -5,6 +5,7 @@ require 'graphql/schema/object'
5
5
  module GraphqlPagination
6
6
  end
7
7
 
8
+ require 'graphql_pagination/collection_base_error'
8
9
  require 'graphql_pagination/collection_type'
9
10
  require 'graphql_pagination/collection_metadata_type'
10
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-pagination
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Knapik
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-04-02 00:00:00.000000000 Z
12
+ date: 2022-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphql
@@ -165,6 +165,7 @@ files:
165
165
  - graphql-pagination.gemspec
166
166
  - lib/graphql-pagination.rb
167
167
  - lib/graphql_pagination.rb
168
+ - lib/graphql_pagination/collection_base_error.rb
168
169
  - lib/graphql_pagination/collection_metadata_type.rb
169
170
  - lib/graphql_pagination/collection_type.rb
170
171
  - lib/graphql_pagination/version.rb