File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
src/test/groovy/graphql/analysis Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -293,4 +293,32 @@ class QueryTraversalTest extends Specification {
293
293
294
294
}
295
295
296
+ def " simple reduce" () {
297
+ given :
298
+ def schema = TestUtil . schema("""
299
+ type Query{
300
+ foo: Foo
301
+ bar: String
302
+ }
303
+ type Foo {
304
+ subFoo: String
305
+ }
306
+ """ )
307
+ def visitor = Mock (QueryVisitor )
308
+ def query = createQuery("""
309
+ {bar foo { subFoo} }
310
+ """ )
311
+ QueryTraversal queryTraversal = createQueryTraversal(query, schema, visitor)
312
+ QueryReducer reducer = Mock (QueryReducer )
313
+ when :
314
+ def result = queryTraversal. reduce(reducer, 1 )
315
+
316
+ then :
317
+ 1 * reducer. reduceField(_, 1 ) >> 2
318
+ 1 * reducer. reduceField(_, 2 ) >> 3
319
+ 1 * reducer. reduceField(_, 3 ) >> 4
320
+ result == 4
321
+
322
+ }
323
+
296
324
}
You can’t perform that action at this time.
0 commit comments