graphql-connections 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1206b9dbdd7d135f43b52b0a62b4d28b4d5d8c93bb5e8a18800ef5abcc5a6157
|
4
|
+
data.tar.gz: 509ba8323078d1dee9095c18ec227b8416967ad0ce51bb4e3bd2806f09a28a57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63f191221ff5b1e2133ad84bb8cb377941cad75de324310f18734729f5a519dae01f466a88539e895a155f32e39eccfab60f423271a220b4cf3fcfa33bfdbb3b
|
7
|
+
data.tar.gz: da4d990bcc8941fbce16049f0a4ea6aa642f73194a34bfb757c1c0080bd16da1736e4466f2ee7f2868dcc5ceebc8677b745a6c3ea43328561af8ad09f9c9e71f
|
data/README.md
CHANGED
@@ -3,10 +3,7 @@
|
|
3
3
|
|
4
4
|
# GraphQL::Connections
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
Implements [Relay specification](https://relay.dev/graphql/connections.htm) for serving stable connections based on column values.
|
9
|
-
If objects are created or destroyed during pagination, the list of items won’t be disrupted.
|
6
|
+
Additional implementations of cursor-based paginations for [GraphQL Ruby](https://graphql-ruby.org/).
|
10
7
|
|
11
8
|
<a href="https://evilmartians.com/?utm_source=graphql-connections">
|
12
9
|
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
|
@@ -23,6 +20,9 @@ gem "graphql-connections"
|
|
23
20
|
|
24
21
|
### ActiveRecord
|
25
22
|
|
23
|
+
Implements [Relay specification](https://relay.dev/graphql/connections.htm) for serving stable connections based on column values.
|
24
|
+
If objects are created or destroyed during pagination, the list of items won’t be disrupted.
|
25
|
+
|
26
26
|
You can use a stable connection wrapper on a specific field:
|
27
27
|
|
28
28
|
```ruby
|
@@ -95,6 +95,7 @@ field :messages, Types::Message.connection_type, null: false
|
|
95
95
|
def messages
|
96
96
|
CitiesIndex.query(match: {name: "Moscow"})
|
97
97
|
end
|
98
|
+
```
|
98
99
|
|
99
100
|
**NOTE:** Using `first` and `last`arguments simultaneously is not supported yet.
|
100
101
|
|
@@ -22,11 +22,11 @@ module GraphQL
|
|
22
22
|
@nodes ||= limited_relation
|
23
23
|
end
|
24
24
|
|
25
|
-
def has_previous_page
|
25
|
+
def has_previous_page
|
26
26
|
raise NotImplementedError
|
27
27
|
end
|
28
28
|
|
29
|
-
def has_next_page
|
29
|
+
def has_next_page
|
30
30
|
raise NotImplementedError
|
31
31
|
end
|
32
32
|
|
@@ -10,7 +10,7 @@ module GraphQL
|
|
10
10
|
super(*args, **kwargs)
|
11
11
|
end
|
12
12
|
|
13
|
-
def has_previous_page
|
13
|
+
def has_previous_page
|
14
14
|
if last
|
15
15
|
nodes.any? && items.where(arel_table[primary_key].lt(nodes.first[primary_key])).exists?
|
16
16
|
elsif after
|
@@ -20,7 +20,7 @@ module GraphQL
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def has_next_page
|
23
|
+
def has_next_page
|
24
24
|
if first
|
25
25
|
nodes.any? && items.where(arel_table[primary_key].gt(nodes.last[primary_key])).exists?
|
26
26
|
elsif before
|
@@ -38,7 +38,7 @@ module GraphQL
|
|
38
38
|
|
39
39
|
private
|
40
40
|
|
41
|
-
def limited_relation
|
41
|
+
def limited_relation
|
42
42
|
scope = sliced_relation
|
43
43
|
nodes = []
|
44
44
|
|
@@ -59,7 +59,7 @@ module GraphQL
|
|
59
59
|
nodes
|
60
60
|
end
|
61
61
|
|
62
|
-
def sliced_relation
|
62
|
+
def sliced_relation
|
63
63
|
items
|
64
64
|
.yield_self { |s| after ? s.where(arel_table[primary_key].gt(after_cursor)) : s }
|
65
65
|
.yield_self { |s| before ? s.where(arel_table[primary_key].lt(before_cursor)) : s }
|
@@ -5,7 +5,6 @@ module GraphQL
|
|
5
5
|
module Keyset
|
6
6
|
# Implements keyset pagination by two fields with asc order
|
7
7
|
class Asc < ::GraphQL::Connections::Keyset::Base
|
8
|
-
# rubocop:disable Naming/PredicateName, Metrics/AbcSize, Metrics/MethodLength
|
9
8
|
def has_previous_page
|
10
9
|
if last
|
11
10
|
nodes.any? &&
|
@@ -47,7 +46,7 @@ module GraphQL
|
|
47
46
|
|
48
47
|
private
|
49
48
|
|
50
|
-
def limited_relation
|
49
|
+
def limited_relation
|
51
50
|
scope = sliced_relation
|
52
51
|
nodes = []
|
53
52
|
|
@@ -66,14 +65,14 @@ module GraphQL
|
|
66
65
|
nodes
|
67
66
|
end
|
68
67
|
|
69
|
-
def sliced_relation_after(relation)
|
68
|
+
def sliced_relation_after(relation)
|
70
69
|
relation
|
71
70
|
.where(arel_table[field_key].eq(after_cursor_date))
|
72
71
|
.where(arel_table[primary_key].gt(after_cursor_primary_key))
|
73
72
|
.or(relation.where(arel_table[field_key].gt(after_cursor_date)))
|
74
73
|
end
|
75
74
|
|
76
|
-
def sliced_relation_before(relation)
|
75
|
+
def sliced_relation_before(relation)
|
77
76
|
relation
|
78
77
|
.where(arel_table[field_key].eq(before_cursor_date))
|
79
78
|
.where(arel_table[primary_key].lt(before_cursor_primary_key))
|
@@ -5,7 +5,6 @@ module GraphQL
|
|
5
5
|
module Keyset
|
6
6
|
# Implements keyset pagination by two fields with desc order
|
7
7
|
class Desc < ::GraphQL::Connections::Keyset::Base
|
8
|
-
# rubocop:disable Naming/PredicateName, Metrics/AbcSize, Metrics/MethodLength
|
9
8
|
def has_previous_page
|
10
9
|
if last
|
11
10
|
nodes.any? &&
|
@@ -53,7 +52,7 @@ module GraphQL
|
|
53
52
|
|
54
53
|
private
|
55
54
|
|
56
|
-
def limited_relation
|
55
|
+
def limited_relation
|
57
56
|
scope = sliced_relation
|
58
57
|
nodes = []
|
59
58
|
|
@@ -73,14 +72,14 @@ module GraphQL
|
|
73
72
|
nodes
|
74
73
|
end
|
75
74
|
|
76
|
-
def sliced_relation_after(relation)
|
75
|
+
def sliced_relation_after(relation)
|
77
76
|
relation
|
78
77
|
.where(arel_table[field_key].eq(after_cursor_date))
|
79
78
|
.where(arel_table[primary_key].lt(after_cursor_primary_key))
|
80
79
|
.or(relation.where(arel_table[field_key].lt(after_cursor_date)))
|
81
80
|
end
|
82
81
|
|
83
|
-
def sliced_relation_before(relation)
|
82
|
+
def sliced_relation_before(relation)
|
84
83
|
relation
|
85
84
|
.where(arel_table[field_key].eq(before_cursor_date))
|
86
85
|
.where(arel_table[primary_key].gt(before_cursor_primary_key))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-connections
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Misha Merkushin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -28,16 +28,22 @@ dependencies:
|
|
28
28
|
name: graphql
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.10'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '3.0'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '1.10'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.0'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: bundler
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
236
|
- !ruby/object:Gem::Version
|
231
237
|
version: '0'
|
232
238
|
requirements: []
|
233
|
-
rubygems_version: 3.
|
239
|
+
rubygems_version: 3.2.32
|
234
240
|
signing_key:
|
235
241
|
specification_version: 4
|
236
242
|
summary: GraphQL cursor-based stable pagination to work with Active Record relations
|