2121import java .util .function .Supplier ;
2222import java .util .stream .Collectors ;
2323
24+ /**
25+ * An enum representing possible context settings. These are modeled after Apollo's link settings.
26+ */
2427public enum ContextSetting {
2528
29+ /**
30+ * A context object, and therefor dataloader registry and subject, should be shared between all GraphQL executions in a http request.
31+ */
2632 PER_REQUEST ,
33+ /**
34+ * Each GraphQL execution should always have its own context.
35+ */
2736 PER_QUERY ;
2837
38+ /**
39+ * Creates a set of inputs with the correct context based on the setting.
40+ * @param requests the GraphQL requests to execute.
41+ * @param schema the GraphQL schema to execute the requests against.
42+ * @param contextSupplier method that returns the context to use for each execution or for the request as a whole.
43+ * @param root the root object to use for each execution.
44+ * @return a configured batch input.
45+ */
2946 public GraphQLBatchedInvocationInput getBatch (List <GraphQLRequest > requests , GraphQLSchema schema , Supplier <GraphQLContext > contextSupplier , Object root ) {
3047 switch (this ) {
3148 case PER_QUERY :
@@ -37,6 +54,13 @@ public GraphQLBatchedInvocationInput getBatch(List<GraphQLRequest> requests, Gra
3754 }
3855 }
3956
57+ /**
58+ * Augments the provided instrumentation supplier to also supply the correct dispatching instrumentation.
59+ * @param instrumentation the instrumentation supplier to augment
60+ * @param executionInputs the inputs that will be dispatched by the instrumentation
61+ * @param options the DataLoader dispatching instrumentation options that will be used.
62+ * @return augmented instrumentation supplier.
63+ */
4064 public Supplier <Instrumentation > configureInstrumentationForContext (Supplier <Instrumentation > instrumentation , List <ExecutionInput > executionInputs ,
4165 DataLoaderDispatcherInstrumentationOptions options ) {
4266 ConfigurableDispatchInstrumentation dispatchInstrumentation ;
0 commit comments