@@ -12,6 +12,7 @@ import graphql.schema.GraphQLNonNull
1212import graphql.schema.GraphQLObjectType
1313import graphql.schema.GraphQLType
1414import graphql.schema.GraphQLTypeUtil
15+ import graphql.schema.TypeResolver
1516import spock.lang.Specification
1617
1718import java.util.function.Function
@@ -22,6 +23,7 @@ import static graphql.TestUtil.mergedField
2223import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition
2324import static graphql.schema.GraphQLList.list
2425import static graphql.schema.GraphQLNonNull.nonNull
26+ import static graphql.schema.GraphQLTypeUtil.simplePrint
2527import static graphql.schema.GraphQLTypeUtil.unwrapAll
2628import static graphql.schema.idl.RuntimeWiring.newRuntimeWiring
2729import static graphql.schema.idl.TypeRuntimeWiring.newTypeWiring
@@ -229,4 +231,87 @@ class ExecutionStepInfoTest extends Specification {
229231 then :
230232 transformed. getFieldContainer() == executionStepInfo. getFieldContainer()
231233 }
234+
235+ def " step info for list of lists of abstract type" () {
236+ def spec = '''
237+ type Query {
238+ pets: [[Pet]]
239+ }
240+
241+ interface Pet {
242+ names : [String]
243+ }
244+ type Cat implements Pet {
245+ names : [String]
246+ }
247+ type Dog implements Pet {
248+ names : [String]
249+ }
250+ '''
251+
252+ def dog = [name : " Dog" , __typename : " Dog" ]
253+ def cat = [name : " Cat" , __typename : " Cat" ]
254+ def petTypeResolver = { it -> it. schema. getObjectType(it. object. __typename) } as TypeResolver
255+
256+
257+ ExecutionStepInfo dogStepInfo
258+ def dogDf = { it ->
259+ dogStepInfo = it. getExecutionStepInfo()
260+ return null
261+ } as DataFetcher
262+
263+
264+ ExecutionStepInfo catStepInfo
265+ def catDf = { it ->
266+ catStepInfo = it. getExecutionStepInfo()
267+ return null
268+ } as DataFetcher
269+
270+ def pets = [[dog], [cat]]
271+ def runtimeWiring = newRuntimeWiring()
272+ .type(newTypeWiring(" Query" ). dataFetcher(" pets" , { it -> pets }))
273+ .type(newTypeWiring(" Pet" ). typeResolver(petTypeResolver). build())
274+ .type(newTypeWiring(" Cat" ). dataFetcher(" names" , catDf). build())
275+ .type(newTypeWiring(" Dog" ). dataFetcher(" names" , dogDf). build())
276+ .build()
277+
278+ def graphQL = TestUtil . graphQL(spec, runtimeWiring). build()
279+
280+ def query = '''
281+ {
282+ pets {names}
283+ }
284+ '''
285+ def executionInput = ExecutionInput . newExecutionInput(). query(query). build()
286+ when :
287+ graphQL. execute(executionInput)
288+ then :
289+ // dog info
290+ dogStepInfo. path. toString() == " /pets[0][0]/names"
291+ simplePrint(dogStepInfo. type) == " [String]"
292+
293+ dogStepInfo. parent. path. toString() == " /pets[0][0]"
294+ simplePrint(dogStepInfo. parent. type) == " Dog"
295+
296+ dogStepInfo. parent. parent. path. toString() == " /pets[0]"
297+ simplePrint(dogStepInfo. parent. parent. type) == " [Pet]"
298+
299+ dogStepInfo. parent. parent. parent. path. toString() == " /pets"
300+ simplePrint(dogStepInfo. parent. parent. parent. type) == " [[Pet]]"
301+
302+ // cat info
303+ catStepInfo. path. toString() == " /pets[1][0]/names"
304+ simplePrint(catStepInfo. type) == " [String]"
305+
306+ catStepInfo. parent. path. toString() == " /pets[1][0]"
307+ simplePrint(catStepInfo. parent. type) == " Cat"
308+
309+ catStepInfo. parent. parent. path. toString() == " /pets[1]"
310+ simplePrint(catStepInfo. parent. parent. type) == " [Pet]"
311+
312+ catStepInfo. parent. parent. parent. path. toString() == " /pets"
313+ simplePrint(catStepInfo. parent. parent. parent. type) == " [[Pet]]"
314+
315+
316+ }
232317}
0 commit comments