11package graphql ;
22
3+ import graphql .cachecontrol .CacheControl ;
34import org .dataloader .DataLoaderRegistry ;
45
56import java .util .Collections ;
@@ -20,20 +21,22 @@ public class ExecutionInput {
2021 private final Object root ;
2122 private final Map <String , Object > variables ;
2223 private final DataLoaderRegistry dataLoaderRegistry ;
24+ private final CacheControl cacheControl ;
2325
2426
2527 public ExecutionInput (String query , String operationName , Object context , Object root , Map <String , Object > variables ) {
26- this (query , operationName , context , root , variables , new DataLoaderRegistry ());
28+ this (query , operationName , context , root , variables , new DataLoaderRegistry (), null );
2729 }
2830
2931 @ Internal
30- private ExecutionInput (String query , String operationName , Object context , Object root , Map <String , Object > variables , DataLoaderRegistry dataLoaderRegistry ) {
32+ private ExecutionInput (String query , String operationName , Object context , Object root , Map <String , Object > variables , DataLoaderRegistry dataLoaderRegistry , CacheControl cacheControl ) {
3133 this .query = query ;
3234 this .operationName = operationName ;
3335 this .context = context ;
3436 this .root = root ;
3537 this .variables = variables ;
3638 this .dataLoaderRegistry = dataLoaderRegistry ;
39+ this .cacheControl = cacheControl ;
3740 }
3841
3942 /**
@@ -78,6 +81,13 @@ public DataLoaderRegistry getDataLoaderRegistry() {
7881 return dataLoaderRegistry ;
7982 }
8083
84+ /**
85+ * @return the cache control helper associated with this execution
86+ */
87+ public CacheControl getCacheControl () {
88+ return cacheControl ;
89+ }
90+
8191 /**
8292 * This helps you transform the current ExecutionInput object into another one by starting a builder with all
8393 * the current values and allows you to transform it how you want.
@@ -93,6 +103,7 @@ public ExecutionInput transform(Consumer<Builder> builderConsumer) {
93103 .context (this .context )
94104 .root (this .root )
95105 .dataLoaderRegistry (this .dataLoaderRegistry )
106+ .cacheControl (this .cacheControl )
96107 .variables (this .variables );
97108
98109 builderConsumer .accept (builder );
@@ -139,6 +150,7 @@ public static class Builder {
139150 private Object root ;
140151 private Map <String , Object > variables = Collections .emptyMap ();
141152 private DataLoaderRegistry dataLoaderRegistry = new DataLoaderRegistry ();
153+ private CacheControl cacheControl ;
142154
143155 public Builder query (String query ) {
144156 this .query = query ;
@@ -196,8 +208,13 @@ public Builder dataLoaderRegistry(DataLoaderRegistry dataLoaderRegistry) {
196208 return this ;
197209 }
198210
211+ public Builder cacheControl (CacheControl cacheControl ) {
212+ this .cacheControl = cacheControl ;
213+ return this ;
214+ }
215+
199216 public ExecutionInput build () {
200- return new ExecutionInput (query , operationName , context , root , variables , dataLoaderRegistry );
217+ return new ExecutionInput (query , operationName , context , root , variables , dataLoaderRegistry , cacheControl );
201218 }
202219 }
203220}
0 commit comments