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 +4 -4
- data/.bundler-version +1 -1
- data/.github/workflows/ci.yml +2 -5
- data/Gemfile.lock +27 -24
- data/README.md +19 -0
- data/Rakefile +1 -1
- data/lib/graphql_pagination/collection_base_error.rb +8 -0
- data/lib/graphql_pagination/collection_type.rb +9 -3
- data/lib/graphql_pagination/version.rb +1 -1
- data/lib/graphql_pagination.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba2564755b00967af752c896752143dae2de5519edc1b3b4528ff653b1a30ef1
|
4
|
+
data.tar.gz: 469bb8190f417420ca82535b854b1dff1c039dea9a0fa5998f3f85df83ae7776
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9517c649c9e976eee72e1144bed30c9bc7f4e5a0eae51822e063605d0a110a66d0706b156b0122a51abb81efa5cd548607de594624453ea9b0addf8e34876757
|
7
|
+
data.tar.gz: 5a3ef06d7912a19bc8c5382873898af974e5bc1f23a130d9cee04a70be2fdb84e58499954057d7ac58bc6d6e3a0ab09eb48311cd2e7d9cf63977dd763e6663dc
|
data/.bundler-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.22
|
data/.github/workflows/ci.yml
CHANGED
@@ -14,12 +14,9 @@ jobs:
|
|
14
14
|
ruby-version: ['3.0', 3.1]
|
15
15
|
|
16
16
|
steps:
|
17
|
-
- uses: actions/checkout@
|
17
|
+
- uses: actions/checkout@v3
|
18
18
|
- name: Set up Ruby
|
19
|
-
|
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.
|
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.
|
11
|
-
activesupport (= 7.0.
|
12
|
-
activerecord (7.0.
|
13
|
-
activemodel (= 7.0.
|
14
|
-
activesupport (= 7.0.
|
15
|
-
activesupport (7.0.
|
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.
|
25
|
-
i18n (1.
|
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.
|
33
|
+
minitest (5.16.3)
|
33
34
|
parallel (1.22.1)
|
34
|
-
parser (3.1.1
|
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.
|
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.
|
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.
|
56
|
-
rubocop (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.
|
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.
|
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.
|
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.
|
70
|
-
rubocop (~> 1.
|
71
|
+
rubocop-rspec (2.13.2)
|
72
|
+
rubocop (~> 1.33)
|
71
73
|
ruby-progressbar (1.11.0)
|
72
|
-
tzinfo (2.0.
|
74
|
+
tzinfo (2.0.5)
|
73
75
|
concurrent-ruby (~> 1.0)
|
74
|
-
unicode-display_width (2.
|
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.
|
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
@@ -1,12 +1,18 @@
|
|
1
1
|
module GraphqlPagination
|
2
2
|
module CollectionType
|
3
|
-
def collection_type(
|
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[
|
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(
|
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
|
data/lib/graphql_pagination.rb
CHANGED
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.
|
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-
|
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
|