7
7
import graphql .execution .instrumentation .Instrumentation ;
8
8
import graphql .execution .instrumentation .SimpleInstrumentation ;
9
9
import graphql .execution .instrumentation .dataloader .DataLoaderDispatcherInstrumentation ;
10
+ import graphql .execution .instrumentation .dataloader .DataLoaderDispatcherInstrumentationOptions ;
10
11
import graphql .execution .preparsed .NoOpPreparsedDocumentProvider ;
11
12
import graphql .execution .preparsed .PreparsedDocumentProvider ;
12
13
import graphql .schema .GraphQLSchema ;
@@ -28,11 +29,13 @@ public class GraphQLQueryInvoker {
28
29
private final Supplier <ExecutionStrategyProvider > getExecutionStrategyProvider ;
29
30
private final Supplier <Instrumentation > getInstrumentation ;
30
31
private final Supplier <PreparsedDocumentProvider > getPreparsedDocumentProvider ;
32
+ private final Supplier <DataLoaderDispatcherInstrumentationOptions > dataLoaderDispatcherInstrumentationOptionsSupplier ;
31
33
32
- protected GraphQLQueryInvoker (Supplier <ExecutionStrategyProvider > getExecutionStrategyProvider , Supplier <Instrumentation > getInstrumentation , Supplier <PreparsedDocumentProvider > getPreparsedDocumentProvider ) {
34
+ protected GraphQLQueryInvoker (Supplier <ExecutionStrategyProvider > getExecutionStrategyProvider , Supplier <Instrumentation > getInstrumentation , Supplier <PreparsedDocumentProvider > getPreparsedDocumentProvider , Supplier < DataLoaderDispatcherInstrumentationOptions > optionsSupplier ) {
33
35
this .getExecutionStrategyProvider = getExecutionStrategyProvider ;
34
36
this .getInstrumentation = getInstrumentation ;
35
37
this .getPreparsedDocumentProvider = getPreparsedDocumentProvider ;
38
+ this .dataLoaderDispatcherInstrumentationOptionsSupplier = optionsSupplier ;
36
39
}
37
40
38
41
public ExecutionResult query (GraphQLSingleInvocationInput singleInvocationInput ) {
@@ -65,7 +68,7 @@ protected Instrumentation getInstrumentation(Object context) {
65
68
.map (registry -> {
66
69
List <Instrumentation > instrumentations = new ArrayList <>();
67
70
instrumentations .add (getInstrumentation .get ());
68
- instrumentations .add (new DataLoaderDispatcherInstrumentation (registry ));
71
+ instrumentations .add (new DataLoaderDispatcherInstrumentation (registry , dataLoaderDispatcherInstrumentationOptionsSupplier . get () ));
69
72
return new ChainedInstrumentation (instrumentations );
70
73
})
71
74
.map (Instrumentation .class ::cast )
@@ -100,6 +103,7 @@ public static class Builder {
100
103
private Supplier <ExecutionStrategyProvider > getExecutionStrategyProvider = DefaultExecutionStrategyProvider ::new ;
101
104
private Supplier <Instrumentation > getInstrumentation = () -> SimpleInstrumentation .INSTANCE ;
102
105
private Supplier <PreparsedDocumentProvider > getPreparsedDocumentProvider = () -> NoOpPreparsedDocumentProvider .INSTANCE ;
106
+ private Supplier <DataLoaderDispatcherInstrumentationOptions > dataLoaderDispatcherInstrumentationOptionsSupplier = DataLoaderDispatcherInstrumentationOptions ::newOptions ;
103
107
104
108
public Builder withExecutionStrategyProvider (ExecutionStrategyProvider provider ) {
105
109
return withExecutionStrategyProvider (() -> provider );
@@ -128,8 +132,17 @@ public Builder withPreparsedDocumentProvider(Supplier<PreparsedDocumentProvider>
128
132
return this ;
129
133
}
130
134
135
+ public Builder withDataLoaderDispatcherInstrumentationOptions (DataLoaderDispatcherInstrumentationOptions options ) {
136
+ return withDataLoaderDispatcherInstrumentationOptions (() -> options );
137
+ }
138
+
139
+ public Builder withDataLoaderDispatcherInstrumentationOptions (Supplier <DataLoaderDispatcherInstrumentationOptions > supplier ) {
140
+ this .dataLoaderDispatcherInstrumentationOptionsSupplier = supplier ;
141
+ return this ;
142
+ }
143
+
131
144
public GraphQLQueryInvoker build () {
132
- return new GraphQLQueryInvoker (getExecutionStrategyProvider , getInstrumentation , getPreparsedDocumentProvider );
145
+ return new GraphQLQueryInvoker (getExecutionStrategyProvider , getInstrumentation , getPreparsedDocumentProvider , dataLoaderDispatcherInstrumentationOptionsSupplier );
133
146
}
134
147
}
135
148
}
0 commit comments