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: ef27f5fb3f9d555769a1328f85b342b65b472e2d282a0e46296ba91441572641
4
- data.tar.gz: dc5a4b2884b5266acad35c37b400fade1ea3850beaa2a03eb2d2974276bcd02a
3
+ metadata.gz: 1206b9dbdd7d135f43b52b0a62b4d28b4d5d8c93bb5e8a18800ef5abcc5a6157
4
+ data.tar.gz: 509ba8323078d1dee9095c18ec227b8416967ad0ce51bb4e3bd2806f09a28a57
5
5
  SHA512:
6
- metadata.gz: 2b7ba37f332c49b5238969a683c1cdfbdcec8c76074d1e3d3903e1d2f8668bed48ea069a55cd65ed49f8ee6dceb7b5022dbfee2d95b1ca8452bb15d1b5d04053
7
- data.tar.gz: 5375969fb009a1e7e7691f19fab5c0c60befc071d4cebf5e73a7854831508ee240e9209daeb4c33cf1f972cda56524fc97862105d2b0e8c0161a14e142fc3f3c
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
- Cursor-based pagination to work with `ActiveRecord::Relation`s.
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 # rubocop:disable Naming/PredicateName
25
+ def has_previous_page
26
26
  raise NotImplementedError
27
27
  end
28
28
 
29
- def has_next_page # rubocop:disable Naming/PredicateName
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 # rubocop:disable Naming/PredicateName, Metrics/AbcSize
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 # rubocop:disable Naming/PredicateName, Metrics/AbcSize
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 # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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 # rubocop:disable Metrics/AbcSize
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 # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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) # rubocop:disable Metrics/AbcSize
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) # rubocop:disable Metrics/AbcSize
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 # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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) # rubocop:disable Metrics/AbcSize
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) # rubocop:disable Metrics/AbcSize
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))
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module Paging
5
- VERSION = "1.1.0"
5
+ VERSION = "1.2.0"
6
6
  end
7
7
  end
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.1.0
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: 2021-07-23 00:00:00.000000000 Z
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.1.2
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