Skip to content

Commit f4c900e

Browse files
committed
test nested streams
1 parent 0d791df commit f4c900e

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

spec/graphql/execution/deferred_execution_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,22 @@ def merged_result
265265
assert_equal({"id"=>3}, collector.patches[3][:value])
266266
end
267267

268+
describe "lists inside @streamed lists" do
269+
let(:query_string) {%|
270+
{
271+
milks @stream {
272+
flavors
273+
}
274+
}
275+
|}
276+
277+
it "streams the outer list but sends the inner list wholesale" do
278+
result
279+
# One with an empty list, then 2 patches
280+
assert_equal(3, collector.patches.length)
281+
end
282+
end
283+
268284
describe "nested defers" do
269285
let(:query_string) {%|
270286
{

spec/support/dairy_app.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ def self.create(type:, data:)
254254
resolve -> (obj, args, ctx) { CHEESES.values }
255255
end
256256
field :milk, field: FetchField.create(type: MilkType, data: MILKS, id_type: !types.ID)
257+
field :milks, types[MilkType] do
258+
resolve -> (obj, args, ctx) { MILKS.values }
259+
end
257260
field :dairy, field: SingletonField.create(type: DairyType, data: DAIRY)
258261
field :fromSource, &SourceFieldDefn
259262
field :favoriteEdible, FavoriteFieldDefn

spec/support/dairy_data.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Milk = Struct.new(:id, :fatContent, :origin, :source, :flavors)
1111
MILKS = {
1212
1 => Milk.new(1, 0.04, "Antiquity", 1, ["Natural", "Chocolate", "Strawberry"]),
13+
2 => Milk.new(2, 0.02, "Antiquity", 1, ["Natural"]),
1314
}
1415

1516
DAIRY = OpenStruct.new(

0 commit comments

Comments
 (0)