graphql-relay 0.4.1 → 0.4.2
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: b27b8ff701421ecd919a8cb16dfe819e42925769
|
4
|
+
data.tar.gz: c87a89aa53e9940ca8c5cf6a822aa3f73f8fec8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: badde6bd6ab29ab7ce5ae3366163491a888e40105cfbf414bbe5c54583d8441a1103d5a8a0fb195df663b410befd9f469362cb9ba5d2dfb3991363b21abd904f
|
7
|
+
data.tar.gz: 9d8a4799e0a570a3be0bc58aa026c9a7e87531cd7caf17705e845f0147c97d11b2e5a10bdca0ece40cfc7994435f1d7f4f162574a31113370950a53753493dd2
|
@@ -24,17 +24,17 @@ module GraphQL
|
|
24
24
|
underlying_field.arguments = underlying_field.arguments.merge(DEFAULT_ARGUMENTS)
|
25
25
|
# TODO: make a public API on GraphQL::Field to expose this proc
|
26
26
|
original_resolve = underlying_field.instance_variable_get(:@resolve_proc)
|
27
|
-
underlying_field.resolve = get_connection_resolve(original_resolve)
|
27
|
+
underlying_field.resolve = get_connection_resolve(underlying_field.name, original_resolve)
|
28
28
|
underlying_field
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
32
32
|
|
33
|
-
def self.get_connection_resolve(underlying_resolve)
|
33
|
+
def self.get_connection_resolve(field_name, underlying_resolve)
|
34
34
|
-> (obj, args, ctx) {
|
35
35
|
items = underlying_resolve.call(obj, args, ctx)
|
36
36
|
if items == GraphQL::Query::DEFAULT_RESOLVE
|
37
|
-
items = obj.public_send(
|
37
|
+
items = obj.public_send(field_name)
|
38
38
|
end
|
39
39
|
connection_class = GraphQL::Relay::BaseConnection.connection_for_items(items)
|
40
40
|
connection_class.new(items, args)
|
@@ -122,7 +122,7 @@ describe GraphQL::Relay::RelationConnection do
|
|
122
122
|
let(:query_string) {%|
|
123
123
|
{
|
124
124
|
empire {
|
125
|
-
|
125
|
+
basesClone {
|
126
126
|
edges {
|
127
127
|
node {
|
128
128
|
name
|
@@ -133,7 +133,7 @@ describe GraphQL::Relay::RelationConnection do
|
|
133
133
|
}|}
|
134
134
|
it "uses default resolve" do
|
135
135
|
result = query(query_string)
|
136
|
-
bases = result["data"]["empire"]["
|
136
|
+
bases = result["data"]["empire"]["basesClone"]["edges"]
|
137
137
|
assert_equal(3, bases.length)
|
138
138
|
end
|
139
139
|
end
|
@@ -37,7 +37,8 @@ rebels = OpenStruct.new({
|
|
37
37
|
id: '1',
|
38
38
|
name: 'Alliance to Restore the Republic',
|
39
39
|
ships: ['1', '2', '3', '4', '5'],
|
40
|
-
bases: Base.where(faction_id: 1)
|
40
|
+
bases: Base.where(faction_id: 1),
|
41
|
+
basesClone: Base.where(faction_id: 1),
|
41
42
|
})
|
42
43
|
|
43
44
|
|
@@ -45,7 +46,8 @@ empire = OpenStruct.new({
|
|
45
46
|
id: '2',
|
46
47
|
name: 'Galactic Empire',
|
47
48
|
ships: ['6', '7', '8'],
|
48
|
-
bases: Base.where(faction_id: 2)
|
49
|
+
bases: Base.where(faction_id: 2),
|
50
|
+
basesClone: Base.where(faction_id: 2),
|
49
51
|
})
|
50
52
|
|
51
53
|
STAR_WARS_DATA = {
|