@@ -5,6 +5,7 @@ import graphql.Scalars
55import graphql.execution.ExecutionStepInfo
66import graphql.execution.instrumentation.ChainedInstrumentation
77import graphql.execution.instrumentation.Instrumentation
8+ import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation
89import graphql.schema.DataFetcher
910import graphql.execution.reactive.SingleSubscriberPublisher
1011import graphql.schema.GraphQLNonNull
@@ -1214,4 +1215,23 @@ class AbstractGraphQLHttpServletSpec extends Specification {
12141215 actualInstrumentation instanceof ChainedInstrumentation
12151216 actualInstrumentation != servletInstrumentation
12161217 }
1218+
1219+ def " getInstrumentation does not add dataloader dispatch instrumentation if one is provided" () {
1220+ setup :
1221+ Instrumentation servletInstrumentation = Mock ()
1222+ DataLoaderDispatcherInstrumentation mockDispatchInstrumentation = Mock ()
1223+ ChainedInstrumentation chainedInstrumentation = new ChainedInstrumentation (Arrays . asList(servletInstrumentation,
1224+ mockDispatchInstrumentation))
1225+ GraphQLContext context = new GraphQLContext (request, response, null , null , null )
1226+ DataLoaderRegistry dlr = Mock ()
1227+ context. setDataLoaderRegistry(dlr)
1228+ SimpleGraphQLHttpServlet simpleGraphQLServlet = SimpleGraphQLHttpServlet
1229+ .newBuilder(TestUtils . createGraphQlSchema())
1230+ .withQueryInvoker(GraphQLQueryInvoker . newBuilder(). withInstrumentation(chainedInstrumentation). build())
1231+ .build();
1232+ when :
1233+ Instrumentation actualInstrumentation = simpleGraphQLServlet. getQueryInvoker(). getInstrumentation(context)
1234+ then :
1235+ actualInstrumentation == chainedInstrumentation
1236+ }
12171237}
0 commit comments