4
4
import graphql .execution .ExecutionId ;
5
5
import graphql .execution .instrumentation .ChainedInstrumentation ;
6
6
import graphql .execution .instrumentation .Instrumentation ;
7
- import graphql .execution .instrumentation .dataloader .DataLoaderDispatcherInstrumentationOptions ;
8
7
import graphql .kickstart .execution .GraphQLRequest ;
9
8
import graphql .kickstart .execution .input .GraphQLBatchedInvocationInput ;
10
9
import graphql .kickstart .execution .input .PerQueryBatchedInvocationInput ;
11
10
import graphql .kickstart .execution .input .PerRequestBatchedInvocationInput ;
12
- import graphql .kickstart .execution .instrumentation .ConfigurableDispatchInstrumentation ;
13
11
import graphql .kickstart .execution .instrumentation .FieldLevelTrackingApproach ;
14
12
import graphql .kickstart .execution .instrumentation .RequestLevelTrackingApproach ;
15
13
import graphql .schema .GraphQLSchema ;
@@ -28,11 +26,9 @@ public enum ContextSetting {
28
26
* A context object, and therefor dataloader registry and subject, should be shared between all
29
27
* GraphQL executions in a http request.
30
28
*/
31
- PER_REQUEST_WITH_INSTRUMENTATION ,
32
- PER_REQUEST_WITHOUT_INSTRUMENTATION ,
29
+ PER_REQUEST ,
33
30
/** Each GraphQL execution should always have its own context. */
34
- PER_QUERY_WITH_INSTRUMENTATION ,
35
- PER_QUERY_WITHOUT_INSTRUMENTATION ;
31
+ PER_QUERY ;
36
32
37
33
/**
38
34
* Creates a set of inputs with the correct context based on the setting.
@@ -50,13 +46,9 @@ public GraphQLBatchedInvocationInput getBatch(
50
46
Supplier <GraphQLKickstartContext > contextSupplier ,
51
47
Object root ) {
52
48
switch (this ) {
53
- case PER_QUERY_WITH_INSTRUMENTATION :
54
- // Intentional fallthrough
55
- case PER_QUERY_WITHOUT_INSTRUMENTATION :
49
+ case PER_QUERY :
56
50
return new PerQueryBatchedInvocationInput (requests , schema , contextSupplier , root , this );
57
- case PER_REQUEST_WITHOUT_INSTRUMENTATION :
58
- // Intentional fallthrough
59
- case PER_REQUEST_WITH_INSTRUMENTATION :
51
+ case PER_REQUEST :
60
52
return new PerRequestBatchedInvocationInput (requests , schema , contextSupplier , root , this );
61
53
default :
62
54
throw new ContextSettingNotConfiguredException ();
@@ -69,43 +61,12 @@ public GraphQLBatchedInvocationInput getBatch(
69
61
*
70
62
* @param instrumentation the instrumentation supplier to augment
71
63
* @param executionInputs the inputs that will be dispatched by the instrumentation
72
- * @param options the DataLoader dispatching instrumentation options that will be used.
64
+ // * @param options the DataLoader dispatching instrumentation options that will be used.
73
65
* @return augmented instrumentation supplier.
74
66
*/
75
67
public Supplier <Instrumentation > configureInstrumentationForContext (
76
68
Supplier <Instrumentation > instrumentation ,
77
- List <ExecutionInput > executionInputs ,
78
- DataLoaderDispatcherInstrumentationOptions options ) {
79
- ConfigurableDispatchInstrumentation dispatchInstrumentation ;
80
- switch (this ) {
81
- case PER_REQUEST_WITH_INSTRUMENTATION :
82
- DataLoaderRegistry registry =
83
- executionInputs .stream ()
84
- .findFirst ()
85
- .map (ExecutionInput ::getDataLoaderRegistry )
86
- .orElseThrow (IllegalArgumentException ::new );
87
- List <ExecutionId > executionIds =
88
- executionInputs .stream ()
89
- .map (ExecutionInput ::getExecutionId )
90
- .collect (Collectors .toList ());
91
- RequestLevelTrackingApproach requestTrackingApproach =
92
- new RequestLevelTrackingApproach (executionIds , registry );
93
- dispatchInstrumentation =
94
- new ConfigurableDispatchInstrumentation (
95
- options , (dataLoaderRegistry -> requestTrackingApproach ));
96
- break ;
97
- case PER_QUERY_WITH_INSTRUMENTATION :
98
- dispatchInstrumentation =
99
- new ConfigurableDispatchInstrumentation (options , FieldLevelTrackingApproach ::new );
100
- break ;
101
- case PER_REQUEST_WITHOUT_INSTRUMENTATION :
102
- // Intentional fallthrough
103
- case PER_QUERY_WITHOUT_INSTRUMENTATION :
104
- return instrumentation ;
105
- default :
106
- throw new ContextSettingNotConfiguredException ();
107
- }
108
- return () ->
109
- new ChainedInstrumentation (Arrays .asList (dispatchInstrumentation , instrumentation .get ()));
69
+ List <ExecutionInput > executionInputs ) {
70
+ return instrumentation ;
110
71
}
111
72
}
0 commit comments