graphql-pagination 1.1.0 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ea955b90a7643f1fbbe2ec88c466e1417b7f9f9d0aecae8c86e3072ea787b26
4
- data.tar.gz: 005f943ce8ca3788992052752f1a5e616f0a502640054e46d6f051347048b6c1
3
+ metadata.gz: ac8eec73e3f4bf23e60cf8cca10cee6066b1f72ba02b4abfe62a5d64a1973b84
4
+ data.tar.gz: d5128484c2d064e47d06a36d3b46404361f2f85873442222882b62c376421363
5
5
  SHA512:
6
- metadata.gz: 6aaa55de384cc91b9e31069e5c3bc2e9970081ba6c04fd95df5dad2ebe391a72d7f050bbb518ebab3b9525a2260eeb931805759d73bb1c705e7c4e6a1043c74f
7
- data.tar.gz: 5904d27c1e2c34aec87cecee6770c0187508f25851e8f0f4e2c1ad87c22593427d54d9a76bd5c425a1f088d8430ec332ad630a6724b6b17e9c02070b3e62cbec
6
+ metadata.gz: e48de20398166c2632c8751978882ec75db86714b2703667886da512813b5c027cdb8ee5e0179229a3a2e2e10a887b683abf4365a6477b441d1586660f9459df
7
+ data.tar.gz: 9006adcb4177edd4fbe1d1f2f03e2778f87faf920ac9ce8caf9e57b1265859cde04677ce9c163c2d68e421dea5f8c43af45695e469ac22af553961c846f6f68f
data/.bundler-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.23
@@ -3,16 +3,14 @@ version: 1
3
3
  update_configs:
4
4
  - package_manager: "ruby:bundler"
5
5
  directory: "/"
6
- update_schedule: "monthly"
6
+ update_schedule: "daily"
7
7
  commit_message:
8
8
  prefix: "[dependabot]"
9
9
  allowed_updates:
10
10
  - match:
11
- update_type: "all"
11
+ dependency_type: "all"
12
+ update_type: "security"
12
13
  automerged_updates:
13
14
  - match:
14
- dependency_type: "development"
15
- update_type: "all"
16
- - match:
17
- dependency_type: "production"
18
- update_type: "all"
15
+ dependency_type: "all"
16
+ update_type: "security:patch"
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to track an issue that has been identified
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Mutation/Query**
24
+
25
+ **URL and HTTP method (for non-GQL):**
26
+
27
+ **Sentry or Logs URL:**
28
+
29
+ **User/authentication details**
30
+ Impacted user name or service account
31
+
32
+ **Additional context**
33
+ Add any other context about the problem here.
@@ -0,0 +1 @@
1
+ blank_issues_enabled: false
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: New story
3
+ about: Add a new story for implementation
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the solution**
11
+ A clear and concise description of what you want to happen.
12
+ When will this feature be done?
13
+
14
+ **Describe the users**
15
+ Who are we building this feature for?
16
+
17
+ **Additional context**
18
+ Add any other context or screenshots about the feature request here.
19
+ Link to any applicable documents describing the feature.
20
+
21
+ **Designs**
22
+ Link to any applicable designs on Invision.
@@ -0,0 +1,6 @@
1
+ ## Description, motivation and context
2
+ <!--- Describe your changes in detail -->
3
+ <!--- Why is this change required? What problem does it solve? -->
4
+
5
+ ## Related issue(s) or PR(s)
6
+ <!--- GH issue number -->
@@ -0,0 +1,16 @@
1
+ # automatically approve PRs submitted by Dependabot or Renofidev
2
+ # this will allow Dependabot to automatically merge dependency update PRs where CI passes
3
+ # from: https://github.com/hmarr/auto-approve-action
4
+ name: Auto approve dependency upgrades PRs
5
+
6
+ on:
7
+ pull_request
8
+
9
+ jobs:
10
+ auto-approve:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: hmarr/auto-approve-action@v2.0.0
14
+ if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' || github.actor == 'renofidev'
15
+ with:
16
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
@@ -0,0 +1,19 @@
1
+ name: automerge
2
+ on:
3
+ pull_request_review:
4
+ types:
5
+ - submitted
6
+ check_suite:
7
+ types:
8
+ - completed
9
+ status: {}
10
+ jobs:
11
+ automerge:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: automerge
15
+ uses: "pascalgn/automerge-action@v0.12.0"
16
+ env:
17
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
18
+ MERGE_METHOD: squash
19
+ MERGE_DELETE_BRANCH: true
@@ -0,0 +1,28 @@
1
+ name: Ruby CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ['2.7', '3.0']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
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@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
23
+ with:
24
+ ruby-version: ${{ matrix.ruby-version }}
25
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
26
+
27
+ - name: Run tests
28
+ run: bundle exec rake ci
data/Gemfile.lock CHANGED
@@ -1,80 +1,85 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql-pagination (1.1.0)
5
- graphql (~> 1.9)
4
+ graphql-pagination (1.2.0)
5
+ graphql (~> 1.12)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (6.0.2.1)
11
- activesupport (= 6.0.2.1)
12
- activerecord (6.0.2.1)
13
- activemodel (= 6.0.2.1)
14
- activesupport (= 6.0.2.1)
15
- activesupport (6.0.2.1)
10
+ activemodel (6.1.4)
11
+ activesupport (= 6.1.4)
12
+ activerecord (6.1.4)
13
+ activemodel (= 6.1.4)
14
+ activesupport (= 6.1.4)
15
+ activesupport (6.1.4)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (>= 0.7, < 2)
18
- minitest (~> 5.1)
19
- tzinfo (~> 1.1)
20
- zeitwerk (~> 2.2)
21
- ast (2.4.0)
22
- coderay (1.1.2)
23
- concurrent-ruby (1.1.6)
24
- diff-lcs (1.3)
25
- graphql (1.10.3)
26
- i18n (1.8.2)
17
+ i18n (>= 1.6, < 2)
18
+ minitest (>= 5.1)
19
+ tzinfo (~> 2.0)
20
+ zeitwerk (~> 2.3)
21
+ ast (2.4.2)
22
+ coderay (1.1.3)
23
+ concurrent-ruby (1.1.9)
24
+ diff-lcs (1.4.4)
25
+ graphql (1.12.13)
26
+ i18n (1.8.10)
27
27
  concurrent-ruby (~> 1.0)
28
- jaro_winkler (1.5.4)
29
- kaminari-activerecord (1.2.0)
28
+ kaminari-activerecord (1.2.1)
30
29
  activerecord
31
- kaminari-core (= 1.2.0)
32
- kaminari-core (1.2.0)
33
- method_source (0.9.2)
34
- minitest (5.14.0)
35
- parallel (1.19.1)
36
- parser (2.7.0.3)
37
- ast (~> 2.4.0)
38
- pry (0.12.2)
39
- coderay (~> 1.1.0)
40
- method_source (~> 0.9.0)
30
+ kaminari-core (= 1.2.1)
31
+ kaminari-core (1.2.1)
32
+ method_source (1.0.0)
33
+ minitest (5.14.4)
34
+ parallel (1.20.1)
35
+ parser (3.0.1.1)
36
+ ast (~> 2.4.1)
37
+ pry (0.14.1)
38
+ coderay (~> 1.1)
39
+ method_source (~> 1.0)
41
40
  rainbow (3.0.0)
42
- rake (13.0.1)
43
- rexml (3.2.4)
44
- rspec (3.9.0)
45
- rspec-core (~> 3.9.0)
46
- rspec-expectations (~> 3.9.0)
47
- rspec-mocks (~> 3.9.0)
48
- rspec-core (3.9.1)
49
- rspec-support (~> 3.9.1)
50
- rspec-expectations (3.9.0)
41
+ rake (13.0.4)
42
+ regexp_parser (2.1.1)
43
+ rexml (3.2.5)
44
+ rspec (3.10.0)
45
+ rspec-core (~> 3.10.0)
46
+ rspec-expectations (~> 3.10.0)
47
+ rspec-mocks (~> 3.10.0)
48
+ rspec-core (3.10.1)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-expectations (3.10.1)
51
51
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.9.0)
53
- rspec-mocks (3.9.1)
52
+ rspec-support (~> 3.10.0)
53
+ rspec-mocks (3.10.2)
54
54
  diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.9.0)
56
- rspec-support (3.9.2)
57
- rubocop (0.80.0)
58
- jaro_winkler (~> 1.5.1)
55
+ rspec-support (~> 3.10.0)
56
+ rspec-support (3.10.2)
57
+ rubocop (1.18.3)
59
58
  parallel (~> 1.10)
60
- parser (>= 2.7.0.1)
59
+ parser (>= 3.0.0.0)
61
60
  rainbow (>= 2.2.2, < 4.0)
61
+ regexp_parser (>= 1.8, < 3.0)
62
62
  rexml
63
+ rubocop-ast (>= 1.7.0, < 2.0)
63
64
  ruby-progressbar (~> 1.7)
64
- unicode-display_width (>= 1.4.0, < 1.7)
65
- rubocop-performance (1.5.2)
66
- rubocop (>= 0.71.0)
67
- rubocop-rspec (1.38.1)
68
- rubocop (>= 0.68.1)
69
- ruby-progressbar (1.10.1)
70
- thread_safe (0.3.6)
71
- tzinfo (1.2.6)
72
- thread_safe (~> 0.1)
73
- unicode-display_width (1.6.1)
74
- zeitwerk (2.2.2)
65
+ unicode-display_width (>= 1.4.0, < 3.0)
66
+ rubocop-ast (1.7.0)
67
+ parser (>= 3.0.1.1)
68
+ rubocop-rake (0.6.0)
69
+ rubocop (~> 1.0)
70
+ rubocop-rspec (2.4.0)
71
+ rubocop (~> 1.0)
72
+ rubocop-ast (>= 1.1.0)
73
+ ruby-progressbar (1.11.0)
74
+ tzinfo (2.0.4)
75
+ concurrent-ruby (~> 1.0)
76
+ unicode-display_width (2.0.0)
77
+ zeitwerk (2.4.2)
75
78
 
76
79
  PLATFORMS
77
80
  ruby
81
+ x86_64-darwin-20
82
+ x86_64-linux
78
83
 
79
84
  DEPENDENCIES
80
85
  graphql-pagination!
@@ -84,8 +89,8 @@ DEPENDENCIES
84
89
  rake
85
90
  rspec
86
91
  rubocop
87
- rubocop-performance
92
+ rubocop-rake
88
93
  rubocop-rspec
89
94
 
90
95
  BUNDLED WITH
91
- 2.0.2
96
+ 2.2.23
data/README.md CHANGED
@@ -22,17 +22,16 @@ Add `graphql-pagination` to your Gemfile, you can use `kaminari-activerecord` or
22
22
  argument :limit, Integer, required: false
23
23
  end
24
24
 
25
- def fruit(page: nil, limit: nil)
25
+ def fruits(page: nil, limit: nil)
26
26
  ::Fruit.page(page).per(limit)
27
27
  end
28
28
  ```
29
29
 
30
30
  Value returned by query resolver must be a kaminari object or implements its page scope methods (`current_page`, `limit_value`, `total_count`, `total_pages`).
31
31
 
32
-
33
32
  ## GraphQL query
34
33
 
35
- ```
34
+ ```graphql
36
35
  {
37
36
  fruits(page: 2, limit: 2) {
38
37
  collection {
@@ -49,31 +48,54 @@ Value returned by query resolver must be a kaminari object or implements its pag
49
48
  }
50
49
  ```
51
50
 
52
- ```
51
+ ```json
53
52
  {
54
- 'data': {
55
- 'checklists': {
56
- 'collection': [
53
+ "data": {
54
+ "checklists": {
55
+ "collection": [
57
56
  {
58
- 'id': '93938bb3-7a6c-4d35-9961-cbb2d4c9e9ac',
59
- 'name': 'Apple'
57
+ "id": "93938bb3-7a6c-4d35-9961-cbb2d4c9e9ac",
58
+ "name": "Apple"
60
59
  },
61
60
  {
62
- 'id': 'b1ee93b2-579a-4107-8454-119bba5afb63',
63
- 'name': 'Mango'
61
+ "id": "b1ee93b2-579a-4107-8454-119bba5afb63",
62
+ "name": "Mango"
64
63
  }
65
64
  ],
66
- 'metadata': {
67
- 'totalPages': 25,
68
- 'totalCount': 50,
69
- 'currentPage': 2,
70
- 'limitValue': 2
65
+ "metadata": {
66
+ "totalPages": 25,
67
+ "totalCount": 50,
68
+ "currentPage": 2,
69
+ "limitValue": 2
71
70
  }
72
71
  }
73
72
  }
74
73
  }
75
74
  ```
76
75
 
76
+ ## Custom Metadata
77
+
78
+ By default, the following fields are present in the metadata block:
79
+
80
+ ```graphql
81
+ metadata {
82
+ totalPages
83
+ totalCount
84
+ currentPage
85
+ limitValue
86
+ }
87
+ ```
88
+
89
+ These fields correspond to the `GraphqlPagination::CollectionMetadataType` used to provide the pagination information for the collection of data delivered. If you want to add more metadata fields to this block, you can do so by extending this `CollectionMetadataType`:
90
+
91
+ ```ruby
92
+ class MyMetadataType < GraphqlPagination::CollectionMetadataType
93
+ field :custom_field, String, null: false
94
+ end
95
+
96
+ field :fruits, Types::FruitType.collection_type(metadata_type: MyMetadataType)
97
+ ```
98
+
77
99
  ## Contributing
78
100
 
79
101
  Bug reports and pull requests are welcome on GitHub at https://github.com/renofi/graphql-pagination. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -81,4 +103,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/renofi
81
103
  ## License
82
104
 
83
105
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
84
-
data/Rakefile CHANGED
@@ -5,4 +5,5 @@ require 'rubocop/rake_task'
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
  RuboCop::RakeTask.new
7
7
 
8
- task default: %i[rubocop spec]
8
+ task ci: %i[spec rubocop]
9
+ task default: %i[spec rubocop:auto_correct]
@@ -23,9 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ['lib']
25
25
 
26
- spec.required_ruby_version = '>= 2.6'
26
+ spec.required_ruby_version = '>= 2.7'
27
27
 
28
- spec.add_dependency 'graphql', '~> 1.9'
28
+ spec.add_dependency 'graphql', '~> 1.12'
29
29
 
30
30
  spec.add_development_dependency 'kaminari-activerecord'
31
31
  spec.add_development_dependency 'kaminari-core'
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'rake'
34
34
  spec.add_development_dependency 'rspec'
35
35
  spec.add_development_dependency 'rubocop'
36
- spec.add_development_dependency 'rubocop-performance'
36
+ spec.add_development_dependency 'rubocop-rake'
37
37
  spec.add_development_dependency 'rubocop-rspec'
38
38
  end
@@ -5,7 +5,6 @@ require 'graphql/schema/object'
5
5
  module GraphqlPagination
6
6
  end
7
7
 
8
- require 'graphql_pagination/version'
9
8
  require 'graphql_pagination/collection_type'
10
9
  require 'graphql_pagination/collection_metadata_type'
11
10
 
@@ -1,7 +1,8 @@
1
1
  module GraphqlPagination
2
2
  module CollectionType
3
3
  def collection_type(metadata_type: GraphqlPagination::CollectionMetadataType)
4
- @collection_type ||= begin
4
+ @collection_types ||= {}
5
+ @collection_types[metadata_type] ||= begin
5
6
  type_name = "#{graphql_name}Collection"
6
7
  source_type = self
7
8
 
@@ -1,3 +1,3 @@
1
1
  module GraphqlPagination
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-pagination
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Knapik
8
8
  - RenoFi Engineering Team
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-02-28 00:00:00.000000000 Z
12
+ date: 2021-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphql
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.9'
20
+ version: '1.12'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.9'
27
+ version: '1.12'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: kaminari-activerecord
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +110,7 @@ dependencies:
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  - !ruby/object:Gem::Dependency
113
- name: rubocop-performance
113
+ name: rubocop-rake
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - ">="
@@ -146,10 +146,17 @@ executables: []
146
146
  extensions: []
147
147
  extra_rdoc_files: []
148
148
  files:
149
+ - ".bundler-version"
149
150
  - ".dependabot/config.yml"
151
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
152
+ - ".github/ISSUE_TEMPLATE/config.yml"
153
+ - ".github/ISSUE_TEMPLATE/story.md"
154
+ - ".github/PULL_REQUEST_TEMPLATE.md"
155
+ - ".github/workflows/auto-approve.yml"
156
+ - ".github/workflows/auto-merge.yml"
157
+ - ".github/workflows/ci.yml"
150
158
  - ".gitignore"
151
159
  - ".rspec"
152
- - ".travis.yml"
153
160
  - Gemfile
154
161
  - Gemfile.lock
155
162
  - LICENSE
@@ -167,7 +174,7 @@ licenses:
167
174
  metadata:
168
175
  homepage_uri: https://github.com/RenoFi/graphql-pagination
169
176
  source_code_uri: https://github.com/RenoFi/graphql-pagination
170
- post_install_message:
177
+ post_install_message:
171
178
  rdoc_options: []
172
179
  require_paths:
173
180
  - lib
@@ -175,15 +182,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
182
  requirements:
176
183
  - - ">="
177
184
  - !ruby/object:Gem::Version
178
- version: '2.6'
185
+ version: '2.7'
179
186
  required_rubygems_version: !ruby/object:Gem::Requirement
180
187
  requirements:
181
188
  - - ">="
182
189
  - !ruby/object:Gem::Version
183
190
  version: '0'
184
191
  requirements: []
185
- rubygems_version: 3.0.6
186
- signing_key:
192
+ rubygems_version: 3.2.23
193
+ signing_key:
187
194
  specification_version: 4
188
195
  summary: Page-based kaminari pagination for graphql.
189
196
  test_files: []
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6
7
- before_install: gem install bundler
8
- script:
9
- - bundle exec rake spec
10
- - bundle exec rake rubocop