Skip to content

Commit b47bbef

Browse files
committed
spec(Query) add spec for merging arrays
1 parent 388e065 commit b47bbef

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

spec/graphql/query_spec.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,18 @@
9494
cheese {
9595
flavor
9696
}
97+
milks {
98+
id
99+
}
97100
}
98101
99102
fragment fatContentFragment on Dairy {
100103
cheese {
101104
fatContent
102105
}
106+
milks {
107+
fatContent
108+
}
103109
}
104110
105111
|}
@@ -110,7 +116,13 @@
110116
"cheese" => {
111117
"flavor" => "Brie",
112118
"fatContent" => 0.19
113-
}
119+
},
120+
"milks" => [
121+
{
122+
"id" => "1",
123+
"fatContent" => 0.04,
124+
}
125+
],
114126
}
115127
}}
116128
assert_equal(expected, result)

spec/support/dairy_app.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
description 'A farm where milk is harvested and cheese is produced'
6868
field :id, !types.ID
6969
field :cheese, CheeseType
70-
field :milk, MilkType
70+
field :milks, types[MilkType]
7171
end
7272

7373
MaybeNullType = GraphQL::ObjectType.define do

spec/support/dairy_data.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,4 @@
1010
1 => Milk.new(1, 0.04, 1),
1111
}
1212

13-
Dairy = Struct.new(:cheese)
14-
DAIRY = Dairy.new(CHEESES[1])
15-
13+
DAIRY = OpenStruct.new(cheese: CHEESES[1], milks: [MILKS[1]])

0 commit comments

Comments
 (0)