@@ -5,6 +5,7 @@ import graphql.Scalars
5
5
import graphql.execution.ExecutionStepInfo
6
6
import graphql.execution.instrumentation.ChainedInstrumentation
7
7
import graphql.execution.instrumentation.Instrumentation
8
+ import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation
8
9
import graphql.schema.DataFetcher
9
10
import graphql.execution.reactive.SingleSubscriberPublisher
10
11
import graphql.schema.GraphQLNonNull
@@ -1214,4 +1215,23 @@ class AbstractGraphQLHttpServletSpec extends Specification {
1214
1215
actualInstrumentation instanceof ChainedInstrumentation
1215
1216
actualInstrumentation != servletInstrumentation
1216
1217
}
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
+ }
1217
1237
}
0 commit comments