|
1 | 1 | package graphql.servlet;
|
2 | 2 |
|
| 3 | +import java.util.ArrayList; |
3 | 4 | import java.util.List;
|
4 | 5 | import java.util.Optional;
|
5 | 6 |
|
6 | 7 | import javax.servlet.http.HttpServletRequest;
|
7 | 8 | import javax.servlet.http.HttpServletResponse;
|
8 | 9 |
|
9 | 10 | import graphql.execution.ExecutionStrategy;
|
| 11 | +import graphql.execution.instrumentation.ChainedInstrumentation; |
10 | 12 | import graphql.execution.instrumentation.Instrumentation;
|
11 | 13 | import graphql.execution.instrumentation.SimpleInstrumentation;
|
12 | 14 | import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation;
|
13 | 15 | import graphql.execution.preparsed.NoOpPreparsedDocumentProvider;
|
14 | 16 | import graphql.execution.preparsed.PreparsedDocumentProvider;
|
15 | 17 | import graphql.schema.GraphQLSchema;
|
16 | 18 |
|
| 19 | + |
| 20 | + |
17 | 21 | /**
|
18 | 22 | * @author Andrew Potter
|
19 | 23 | */
|
20 | 24 | public class SimpleGraphQLServlet extends GraphQLServlet {
|
21 |
| - |
| 25 | + |
22 | 26 |
|
23 | 27 | /**
|
24 | 28 | * @deprecated use {@link #builder(GraphQLSchema)} instead.
|
@@ -52,7 +56,7 @@ public SimpleGraphQLServlet(final GraphQLSchema schema, ExecutionStrategyProvide
|
52 | 56 | this(new DefaultGraphQLSchemaProvider(schema), executionStrategyProvider, objectMapperConfigurer, listeners, instrumentation, errorHandler, contextBuilder, rootObjectBuilder, preparsedDocumentProvider,false);
|
53 | 57 | }
|
54 | 58 |
|
55 |
| - |
| 59 | + |
56 | 60 | /**
|
57 | 61 | * @deprecated use {@link #builder(GraphQLSchemaProvider)} instead.
|
58 | 62 | */
|
@@ -189,7 +193,7 @@ public Builder withListeners(List<GraphQLServletListener> listeners) {
|
189 | 193 | this.listeners = listeners;
|
190 | 194 | return this;
|
191 | 195 | }
|
192 |
| - |
| 196 | + |
193 | 197 | public Builder withAsyncServletMode(boolean value) {
|
194 | 198 | this.asyncServletMode=value;
|
195 | 199 | return this;
|
@@ -223,7 +227,13 @@ protected ExecutionStrategyProvider getExecutionStrategyProvider() {
|
223 | 227 | @Override
|
224 | 228 | protected Instrumentation getInstrumentation(GraphQLContext context) {
|
225 | 229 | return context.getDataLoaderRegistry()
|
226 |
| - .map(DataLoaderDispatcherInstrumentation::new) |
| 230 | + .map(registry -> { |
| 231 | + List<Instrumentation> instrumentations = new ArrayList<>(); |
| 232 | + instrumentations.add(this.instrumentation); |
| 233 | + instrumentations.add(new DataLoaderDispatcherInstrumentation(registry)); |
| 234 | + |
| 235 | + return new ChainedInstrumentation(instrumentations); |
| 236 | + }) |
227 | 237 | .map(Instrumentation.class::cast)
|
228 | 238 | .orElse(this.instrumentation);
|
229 | 239 | }
|
|
0 commit comments