relay-rb 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relay/connection/array.rb +6 -0
- data/lib/relay/version.rb +1 -1
- data/spec/connection/connection_spec.rb +1 -3
- data/spec/node/node_global_spec.rb +6 -8
- data/spec/node/node_plural_spec.rb +1 -3
- data/spec/node/node_spec.rb +14 -18
- data/spec/star_wars/connection_spec.rb +5 -5
- data/spec/star_wars/object_identification_spec.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2b88cc9e55e5e4348409677bac655de2347f0da
|
4
|
+
data.tar.gz: 3eac961501cc795b1b32c31387d408791cc131e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00aa9cc861114b2d5b18bd8f9bfdf8244834ee271bf9fd273cfe68d2258fed79865254f4b95102d84ff49c033ec143fed29d426994485ca83b9fbda0d42948ac
|
7
|
+
data.tar.gz: 7524eea2abe1a402b7789ed5e5a0c26a227a135fff48bc75d12179da7d29ada4c9ef00bbeef324fe2a34d00af64a4e5649cdec5f63bf507efac51420e8fcb8c5
|
@@ -11,6 +11,12 @@ module Relay
|
|
11
11
|
EmptyConnection = ArrayConnection.new([], PageInfo.new(nil, nil, false, false))
|
12
12
|
|
13
13
|
def self.connection_from_array(data, args)
|
14
|
+
return EmptyConnection if data.nil?
|
15
|
+
|
16
|
+
return GraphQL::Execution::Pool.future do
|
17
|
+
connection_from_array(data.value, args)
|
18
|
+
end if data.is_a?(Celluloid::Future)
|
19
|
+
|
14
20
|
edges = data.each_with_index.map { |item, i| Edge.new(offset_to_cursor(i), item) }
|
15
21
|
|
16
22
|
start = [get_offset(args[:after], -1), -1].max + 1
|
data/lib/relay/version.rb
CHANGED
@@ -74,9 +74,7 @@ RSpec.describe 'Relay Connection' do
|
|
74
74
|
|
75
75
|
|
76
76
|
it "Should include connections and edge fields" do
|
77
|
-
|
78
|
-
executor = GraphQL::Executor.new(document, ConnectionSchema)
|
79
|
-
puts executor.execute({})
|
77
|
+
puts GraphQL::graphql(ConnectionSchema, q1)
|
80
78
|
end
|
81
79
|
|
82
80
|
|
@@ -34,17 +34,15 @@ RSpec.describe 'Relay Node with Global ID' do
|
|
34
34
|
|
35
35
|
|
36
36
|
it "Should give different ids" do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
expect(executor.execute({})).to eq(expectations)
|
37
|
+
expectation = { data: {all: [{id: 'VXNlcjox'}, {id: 'VXNlcjoy'}, {id: 'UGhvdG86Mw=='}, {id: 'UGhvdG86NA=='}]} }
|
38
|
+
result = GraphQL::graphql(schema, all_q1)
|
39
|
+
expect(result).to eq(expectation)
|
41
40
|
end
|
42
41
|
|
43
42
|
it "Should refetch ids" do
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
expect(executor.execute({})).to eq(expectations)
|
43
|
+
expectation = { data: {user: {id: 'VXNlcjox', name: 'John Doe'}, photo: {id: 'UGhvdG86Mw==', width: 300}} }
|
44
|
+
result = GraphQL::graphql(schema, all_q2)
|
45
|
+
expect(result).to eq(expectation)
|
48
46
|
end
|
49
47
|
|
50
48
|
end
|
@@ -43,9 +43,7 @@ RSpec.describe 'Relay Node Plural' do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "Should allow fetching" do
|
46
|
-
|
47
|
-
executor = GraphQL::Executor.new(document, Schema)
|
48
|
-
puts executor.execute({})
|
46
|
+
puts GraphQL::graphql(Schema, q1)
|
49
47
|
end
|
50
48
|
|
51
49
|
end
|
data/spec/node/node_spec.rb
CHANGED
@@ -65,42 +65,38 @@ RSpec.describe 'Relay Node' do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'Should get correct id for users' do
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
expect(executor.execute({})).to eq(user_expect)
|
68
|
+
expectation = { data: { node: { id: '1' }} }
|
69
|
+
result = GraphQL::graphql(schema, user_q1)
|
70
|
+
expect(result).to eq(expectation)
|
72
71
|
end
|
73
72
|
|
74
73
|
it 'Should get correct id for photos' do
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
expect(executor.execute({})).to eq(photo_expect)
|
74
|
+
expectation = { data: { node: { id: '4' }} }
|
75
|
+
result = GraphQL::graphql(schema, photo_q1)
|
76
|
+
expect(result).to eq(expectation)
|
79
77
|
end
|
80
78
|
|
81
79
|
it 'Should get correct name for users' do
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
expect(executor.execute({})).to eq(user_expect)
|
80
|
+
expectation = { data: { node: { id: '1', name: 'John Doe' }} }
|
81
|
+
result = GraphQL::graphql(schema, user_q2)
|
82
|
+
expect(result).to eq(expectation)
|
86
83
|
end
|
87
84
|
|
88
85
|
it 'Should get correct width for photos' do
|
89
86
|
expectation = { data: { node: { id: '4', width: 400 }}}
|
90
|
-
result = GraphQL::graphql(schema, photo_q2
|
87
|
+
result = GraphQL::graphql(schema, photo_q2)
|
91
88
|
expect(result).to eq(expectation)
|
92
89
|
end
|
93
90
|
|
94
91
|
it 'Should ignore photo fragment on user' do
|
95
92
|
expectation = { data: { node: { id: '1' }}}
|
96
|
-
result = GraphQL::graphql(schema, user_q3
|
93
|
+
result = GraphQL::graphql(schema, user_q3)
|
97
94
|
expect(result).to eq(expectation)
|
98
95
|
end
|
99
96
|
|
100
97
|
it 'Should return null for bad IDs' do
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
expect(executor.execute({})).to eq(nil_expect)
|
98
|
+
expectation = { data: { node: nil } }
|
99
|
+
result = GraphQL::graphql(schema, common_q1)
|
100
|
+
expect(result).to eq(expectation)
|
105
101
|
end
|
106
102
|
end
|
@@ -36,7 +36,7 @@ RSpec.describe "Star Wars connection" do
|
|
36
36
|
}
|
37
37
|
}
|
38
38
|
|
39
|
-
result = GraphQL::graphql(StarWars::Schema, query
|
39
|
+
result = GraphQL::graphql(StarWars::Schema, query)
|
40
40
|
|
41
41
|
expect(result).to eql(expectation)
|
42
42
|
end
|
@@ -82,7 +82,7 @@ RSpec.describe "Star Wars connection" do
|
|
82
82
|
}
|
83
83
|
}
|
84
84
|
|
85
|
-
result = GraphQL::graphql(StarWars::Schema, query
|
85
|
+
result = GraphQL::graphql(StarWars::Schema, query)
|
86
86
|
|
87
87
|
expect(result).to eql(expectation)
|
88
88
|
end
|
@@ -132,7 +132,7 @@ RSpec.describe "Star Wars connection" do
|
|
132
132
|
}
|
133
133
|
}
|
134
134
|
|
135
|
-
result = GraphQL::graphql(StarWars::Schema, query
|
135
|
+
result = GraphQL::graphql(StarWars::Schema, query)
|
136
136
|
|
137
137
|
expect(result).to eql(expectation)
|
138
138
|
end
|
@@ -165,7 +165,7 @@ RSpec.describe "Star Wars connection" do
|
|
165
165
|
}
|
166
166
|
}
|
167
167
|
|
168
|
-
result = GraphQL::graphql(StarWars::Schema, query
|
168
|
+
result = GraphQL::graphql(StarWars::Schema, query)
|
169
169
|
|
170
170
|
expect(result).to eql(expectation)
|
171
171
|
end
|
@@ -244,7 +244,7 @@ RSpec.describe "Star Wars connection" do
|
|
244
244
|
}
|
245
245
|
}
|
246
246
|
|
247
|
-
result = GraphQL::graphql(StarWars::Schema, query
|
247
|
+
result = GraphQL::graphql(StarWars::Schema, query)
|
248
248
|
|
249
249
|
expect(result).to eql(expectation)
|
250
250
|
end
|
@@ -23,7 +23,7 @@ RSpec.describe "Star Wars object identification" do
|
|
23
23
|
}
|
24
24
|
}
|
25
25
|
|
26
|
-
result = GraphQL::graphql(StarWars::Schema, query
|
26
|
+
result = GraphQL::graphql(StarWars::Schema, query)
|
27
27
|
|
28
28
|
expect(result).to eql(expectation)
|
29
29
|
end
|
@@ -50,7 +50,7 @@ RSpec.describe "Star Wars object identification" do
|
|
50
50
|
}
|
51
51
|
}
|
52
52
|
|
53
|
-
result = GraphQL::graphql(StarWars::Schema, query
|
53
|
+
result = GraphQL::graphql(StarWars::Schema, query)
|
54
54
|
|
55
55
|
expect(result).to eql(expectation)
|
56
56
|
end
|
@@ -76,7 +76,7 @@ RSpec.describe "Star Wars object identification" do
|
|
76
76
|
}
|
77
77
|
}
|
78
78
|
|
79
|
-
result = GraphQL::graphql(StarWars::Schema, query
|
79
|
+
result = GraphQL::graphql(StarWars::Schema, query)
|
80
80
|
|
81
81
|
expect(result).to eql(expectation)
|
82
82
|
end
|
@@ -104,7 +104,7 @@ RSpec.describe "Star Wars object identification" do
|
|
104
104
|
}
|
105
105
|
}
|
106
106
|
|
107
|
-
result = GraphQL::graphql(StarWars::Schema, query
|
107
|
+
result = GraphQL::graphql(StarWars::Schema, query)
|
108
108
|
|
109
109
|
expect(result).to eql(expectation)
|
110
110
|
end
|
@@ -131,7 +131,7 @@ RSpec.describe "Star Wars object identification" do
|
|
131
131
|
}
|
132
132
|
}
|
133
133
|
|
134
|
-
result = GraphQL::graphql(StarWars::Schema, query
|
134
|
+
result = GraphQL::graphql(StarWars::Schema, query)
|
135
135
|
|
136
136
|
expect(result).to eql(expectation)
|
137
137
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relay-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Kovalev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|