graphql-relay 0.11.0 → 0.11.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89de18f107f88df71e67a362f1aaa065b002b019
|
4
|
+
data.tar.gz: 25b42d4d63673390f4c6bf0a98443dc770ff3577
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f28ea647cd99aa9134b43d559daef6c030661e0c10fc8b9b8ef568a8ddddd81ca7163b917e0affa7351edf2060dd9a94b5ef25b4724c836d508b3ad9ac45135e
|
7
|
+
data.tar.gz: 75fb99920163c48a84f89696690027d985530d8cde623c19949cb6ba6db83c466a1de78951142b7827749be0f029e8c7a9a158776a4bab512ac893554c9846f4
|
data/README.md
CHANGED
@@ -453,6 +453,7 @@ https://medium.com/@gauravtiwari/graphql-and-relay-on-rails-first-relay-powered-
|
|
453
453
|
- Reduce duplication in ArrayConnection / RelationConnection
|
454
454
|
- Improve API for creating edges (better RANGE_ADD support)
|
455
455
|
- If the new edge isn't a member of the connection's objects, raise a nice error
|
456
|
+
- Rename `Connection#object` => `Connection#collection` with deprecation
|
456
457
|
|
457
458
|
## More Resources
|
458
459
|
|
@@ -44,7 +44,7 @@ module GraphQL
|
|
44
44
|
-> (obj, args, ctx) {
|
45
45
|
items = underlying_resolve.call(obj, args, ctx)
|
46
46
|
connection_class = GraphQL::Relay::BaseConnection.connection_for_items(items)
|
47
|
-
connection_class.new(items, args, max_page_size: max_page_size)
|
47
|
+
connection_class.new(items, args, max_page_size: max_page_size, parent: obj)
|
48
48
|
}
|
49
49
|
end
|
50
50
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module GraphQL
|
2
|
+
module Relay
|
3
|
+
# Helpers for efficient `RANGE_ADD` mutations.
|
4
|
+
#
|
5
|
+
# Add an edge to a connection.
|
6
|
+
# 'append', 'ignore', 'prepend', 'refetch', or 'remove'
|
7
|
+
module RangeAdd
|
8
|
+
RANGE_BEHAVIORS = [
|
9
|
+
# Put the new item at the _start_ of the connection
|
10
|
+
PREPEND = :prepend,
|
11
|
+
# Put the new item at the _end_ of the connection
|
12
|
+
APPEND = :append,
|
13
|
+
# Although the item is added to storage, don't include it in the response
|
14
|
+
IGNORE = :ignore,
|
15
|
+
# Don't try to efficiently calculate the new item's position.
|
16
|
+
# Instead, refetch the whole connection.
|
17
|
+
REFETCH = :refetch,
|
18
|
+
# ???
|
19
|
+
REMOVE = :remove,
|
20
|
+
]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -10,6 +10,7 @@ describe GraphQL::Relay::ConnectionType do
|
|
10
10
|
totalCountTimes100
|
11
11
|
edges {
|
12
12
|
upcasedName
|
13
|
+
upcasedParentName
|
13
14
|
edgeClassName
|
14
15
|
node {
|
15
16
|
name
|
@@ -27,6 +28,9 @@ describe GraphQL::Relay::ConnectionType do
|
|
27
28
|
assert_equal ["YAVIN", "ECHO BASE"] , bases["edges"].map { |e| e["upcasedName"] }
|
28
29
|
assert_equal ["Yavin", "Echo Base"] , bases["edges"].map { |e| e["node"]["name"] }
|
29
30
|
assert_equal ["CustomBaseEdge", "CustomBaseEdge"] , bases["edges"].map { |e| e["edgeClassName"] }
|
31
|
+
upcased_rebels_name = "ALLIANCE TO RESTORE THE REPUBLIC"
|
32
|
+
assert_equal [upcased_rebels_name, upcased_rebels_name] , bases["edges"].map { |e| e["upcasedParentName"] }
|
33
|
+
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
@@ -60,11 +60,16 @@ class CustomBaseEdge < GraphQL::Relay::Edge
|
|
60
60
|
def upcased_name
|
61
61
|
node.name.upcase
|
62
62
|
end
|
63
|
+
|
64
|
+
def upcased_parent_name
|
65
|
+
parent.name.upcase
|
66
|
+
end
|
63
67
|
end
|
64
68
|
|
65
69
|
CustomBaseEdgeType = BaseType.define_edge do
|
66
70
|
name "CustomBaseEdge"
|
67
71
|
field :upcasedName, types.String, property: :upcased_name
|
72
|
+
field :upcasedParentName, types.String, property: :upcased_parent_name
|
68
73
|
field :edgeClassName, types.String do
|
69
74
|
resolve -> (obj, args, ctx) { obj.class.name }
|
70
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-relay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -229,6 +229,7 @@ files:
|
|
229
229
|
- lib/graphql/relay/monkey_patches/base_type.rb
|
230
230
|
- lib/graphql/relay/mutation.rb
|
231
231
|
- lib/graphql/relay/page_info.rb
|
232
|
+
- lib/graphql/relay/range_add.rb
|
232
233
|
- lib/graphql/relay/relation_connection.rb
|
233
234
|
- lib/graphql/relay/version.rb
|
234
235
|
- spec/graphql/relay/array_connection_spec.rb
|
@@ -260,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
260
261
|
version: '0'
|
261
262
|
requirements: []
|
262
263
|
rubyforge_project:
|
263
|
-
rubygems_version: 2.
|
264
|
+
rubygems_version: 2.5.1
|
264
265
|
signing_key:
|
265
266
|
specification_version: 4
|
266
267
|
summary: Relay helpers for GraphQL
|