graphql-pagination 2.0.1 → 2.1.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: b902c58fce73cf2785b2f6a1938f9578c89e9b235c081a6e5c769f0c747acece
4
- data.tar.gz: ee72aa64adb804a3a5458530cc426a3fd98a54d910eaa53cdccb088573ce9361
3
+ metadata.gz: f96c76a2f88c05bf35c37c40d6ad0099a19f1bfa261961d443db8b7965327a59
4
+ data.tar.gz: 1da7d416ffbb3920ca70ea35a5cd6835b27d98068e80496cdc0afc2ffc287b63
5
5
  SHA512:
6
- metadata.gz: cef3d062eb3f7eaf42617fbe44fb4b33400df6ce03d60a6b10715e3a3066c780ad74482a2e78ec11dc382c1a415fb4c8bb96f9a6c02f1f85d89d48c49b36d940
7
- data.tar.gz: 534eda25a1be3daab2259787696e1ea604d040cd8e8ade5883beea90d755acfe6246433742d19579d703bbcda14cc194dcc7b4e10717d1d53666db55cc0dc751
6
+ metadata.gz: 8dde45c4cf39b233bcbc07bf0860632347afc480bbfd4009afee98ec505c0c6352095ef0501eb233f7d42ba9ae4212d7efc74b7aebae1de405ab990026501795
7
+ data.tar.gz: 174ac6aa77bfa23a774c83aaff5d38250a9f57fec2dc673a3f02848ebe8cac06294f2b5bca5744e76552e8209bef48427cf241491585a52665003935d160f88b
data/.bundler-version CHANGED
@@ -1 +1 @@
1
- 2.3.12
1
+ 2.4.5
@@ -14,3 +14,6 @@ update_configs:
14
14
  - match:
15
15
  dependency_type: "all"
16
16
  update_type: "security:patch"
17
+ labels:
18
+ - "automerge"
19
+ - "dependencies"
@@ -0,0 +1,24 @@
1
+ name: automerge-dependencies
2
+ on:
3
+ pull_request_review:
4
+ types:
5
+ - submitted
6
+ check_suite:
7
+ types:
8
+ - completed
9
+ label:
10
+ types:
11
+ - created
12
+ status: {}
13
+ jobs:
14
+ automerge:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: automerge-dependencies
18
+ uses: pascalgn/automerge-action@v0.15.5
19
+ env:
20
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
21
+ MERGE_METHOD: squash
22
+ MERGE_DELETE_BRANCH: true
23
+ MERGE_LABELS: dependencies
24
+ MERGE_REMOVE_LABELS: ""
@@ -6,13 +6,16 @@ on:
6
6
  check_suite:
7
7
  types:
8
8
  - completed
9
+ label:
10
+ types:
11
+ - created
9
12
  status: {}
10
13
  jobs:
11
14
  automerge:
12
15
  runs-on: ubuntu-latest
13
16
  steps:
14
17
  - name: automerge
15
- uses: "pascalgn/automerge-action@v0.12.0"
18
+ uses: pascalgn/automerge-action@v0.15.5
16
19
  env:
17
20
  GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
18
21
  MERGE_METHOD: squash
@@ -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 CHANGED
@@ -1,3 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem 'kaminari-activerecord'
6
+ gem 'kaminari-core'
7
+ gem 'pry'
8
+ gem 'rake'
9
+ gem 'rspec'
10
+ gem 'rubocop'
11
+ gem 'rubocop-rake'
12
+ gem 'rubocop-rspec'
data/Gemfile.lock CHANGED
@@ -1,77 +1,82 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql-pagination (2.0.1)
4
+ graphql-pagination (2.1.1)
5
5
  graphql (~> 2.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (7.0.2.4)
11
- activesupport (= 7.0.2.4)
12
- activerecord (7.0.2.4)
13
- activemodel (= 7.0.2.4)
14
- activesupport (= 7.0.2.4)
15
- activesupport (7.0.2.4)
10
+ activemodel (7.0.4.2)
11
+ activesupport (= 7.0.4.2)
12
+ activerecord (7.0.4.2)
13
+ activemodel (= 7.0.4.2)
14
+ activesupport (= 7.0.4.2)
15
+ activesupport (7.0.4.2)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 1.6, < 2)
18
18
  minitest (>= 5.1)
19
19
  tzinfo (~> 2.0)
20
20
  ast (2.4.2)
21
21
  coderay (1.1.3)
22
- concurrent-ruby (1.1.10)
22
+ concurrent-ruby (1.2.0)
23
23
  diff-lcs (1.5.0)
24
- graphql (2.0.7)
25
- i18n (1.10.0)
24
+ graphql (2.0.16)
25
+ i18n (1.12.0)
26
26
  concurrent-ruby (~> 1.0)
27
+ json (2.6.3)
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.17.0)
33
34
  parallel (1.22.1)
34
- parser (3.1.2.0)
35
+ parser (3.2.1.0)
35
36
  ast (~> 2.4.1)
36
- pry (0.14.1)
37
+ pry (0.14.2)
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.3.1)
42
+ regexp_parser (2.7.0)
42
43
  rexml (3.2.5)
43
- rspec (3.11.0)
44
- rspec-core (~> 3.11.0)
45
- rspec-expectations (~> 3.11.0)
46
- rspec-mocks (~> 3.11.0)
47
- rspec-core (3.11.0)
48
- rspec-support (~> 3.11.0)
49
- rspec-expectations (3.11.0)
44
+ rspec (3.12.0)
45
+ rspec-core (~> 3.12.0)
46
+ rspec-expectations (~> 3.12.0)
47
+ rspec-mocks (~> 3.12.0)
48
+ rspec-core (3.12.1)
49
+ rspec-support (~> 3.12.0)
50
+ rspec-expectations (3.12.2)
50
51
  diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.11.0)
52
- rspec-mocks (3.11.1)
52
+ rspec-support (~> 3.12.0)
53
+ rspec-mocks (3.12.3)
53
54
  diff-lcs (>= 1.2.0, < 2.0)
54
- rspec-support (~> 3.11.0)
55
- rspec-support (3.11.0)
56
- rubocop (1.28.2)
55
+ rspec-support (~> 3.12.0)
56
+ rspec-support (3.12.0)
57
+ rubocop (1.45.1)
58
+ json (~> 2.3)
57
59
  parallel (~> 1.10)
58
- parser (>= 3.1.0.0)
60
+ parser (>= 3.2.0.0)
59
61
  rainbow (>= 2.2.2, < 4.0)
60
62
  regexp_parser (>= 1.8, < 3.0)
61
- rexml
62
- rubocop-ast (>= 1.17.0, < 2.0)
63
+ rexml (>= 3.2.5, < 4.0)
64
+ rubocop-ast (>= 1.24.1, < 2.0)
63
65
  ruby-progressbar (~> 1.7)
64
- unicode-display_width (>= 1.4.0, < 3.0)
65
- rubocop-ast (1.17.0)
66
- parser (>= 3.1.1.0)
66
+ unicode-display_width (>= 2.4.0, < 3.0)
67
+ rubocop-ast (1.26.0)
68
+ parser (>= 3.2.1.0)
69
+ rubocop-capybara (2.17.0)
70
+ rubocop (~> 1.41)
67
71
  rubocop-rake (0.6.0)
68
72
  rubocop (~> 1.0)
69
- rubocop-rspec (2.10.0)
70
- rubocop (~> 1.19)
73
+ rubocop-rspec (2.18.1)
74
+ rubocop (~> 1.33)
75
+ rubocop-capybara (~> 2.17)
71
76
  ruby-progressbar (1.11.0)
72
- tzinfo (2.0.4)
77
+ tzinfo (2.0.6)
73
78
  concurrent-ruby (~> 1.0)
74
- unicode-display_width (2.1.0)
79
+ unicode-display_width (2.4.2)
75
80
 
76
81
  PLATFORMS
77
82
  aarch64-linux-musl
@@ -94,4 +99,4 @@ DEPENDENCIES
94
99
  rubocop-rspec
95
100
 
96
101
  BUNDLED WITH
97
- 2.3.12
102
+ 2.4.1
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]
@@ -27,13 +27,4 @@ Gem::Specification.new do |spec|
27
27
  spec.required_ruby_version = '>= 3.0'
28
28
 
29
29
  spec.add_dependency 'graphql', '~> 2.0'
30
-
31
- spec.add_development_dependency 'kaminari-activerecord'
32
- spec.add_development_dependency 'kaminari-core'
33
- spec.add_development_dependency 'pry'
34
- spec.add_development_dependency 'rake'
35
- spec.add_development_dependency 'rspec'
36
- spec.add_development_dependency 'rubocop'
37
- spec.add_development_dependency 'rubocop-rake'
38
- spec.add_development_dependency 'rubocop-rspec'
39
30
  end
@@ -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.1'.freeze
2
+ VERSION = '2.1.1'.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.1
4
+ version: 2.1.1
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-05-03 00:00:00.000000000 Z
12
+ date: 2023-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphql
@@ -25,118 +25,6 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '2.0'
28
- - !ruby/object:Gem::Dependency
29
- name: kaminari-activerecord
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: kaminari-core
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
- - !ruby/object:Gem::Dependency
57
- name: pry
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: rake
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
- - !ruby/object:Gem::Dependency
85
- name: rspec
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: '0'
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: '0'
98
- - !ruby/object:Gem::Dependency
99
- name: rubocop
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: '0'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: rubocop-rake
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: rubocop-rspec
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: '0'
133
- type: :development
134
- prerelease: false
135
- version_requirements: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: '0'
140
28
  description: Page-based kaminari pagination for graphql returning collection and pagination
141
29
  metadata.
142
30
  email:
@@ -153,6 +41,7 @@ files:
153
41
  - ".github/ISSUE_TEMPLATE/story.md"
154
42
  - ".github/PULL_REQUEST_TEMPLATE.md"
155
43
  - ".github/workflows/auto-approve.yml"
44
+ - ".github/workflows/auto-merge-dependencies.yml"
156
45
  - ".github/workflows/auto-merge.yml"
157
46
  - ".github/workflows/ci.yml"
158
47
  - ".gitignore"
@@ -165,6 +54,7 @@ files:
165
54
  - graphql-pagination.gemspec
166
55
  - lib/graphql-pagination.rb
167
56
  - lib/graphql_pagination.rb
57
+ - lib/graphql_pagination/collection_base_error.rb
168
58
  - lib/graphql_pagination/collection_metadata_type.rb
169
59
  - lib/graphql_pagination/collection_type.rb
170
60
  - lib/graphql_pagination/version.rb
@@ -190,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
80
  - !ruby/object:Gem::Version
191
81
  version: '0'
192
82
  requirements: []
193
- rubygems_version: 3.3.11
83
+ rubygems_version: 3.4.6
194
84
  signing_key:
195
85
  specification_version: 4
196
86
  summary: Page-based kaminari pagination for graphql.