1717
1818import java .util .Collections ;
1919import java .util .List ;
20+ import java .util .Locale ;
2021import java .util .Map ;
2122
2223@ SuppressWarnings ({"unchecked" , "TypeParameterUnusedInFormals" })
@@ -38,6 +39,7 @@ public class DataFetchingEnvironmentImpl implements DataFetchingEnvironment {
3839 private final ExecutionStepInfo executionStepInfo ;
3940 private final DataLoaderRegistry dataLoaderRegistry ;
4041 private final CacheControl cacheControl ;
42+ private final Locale locale ;
4143 private final OperationDefinition operationDefinition ;
4244 private final Document document ;
4345 private final Map <String , Object > variables ;
@@ -60,12 +62,40 @@ private DataFetchingEnvironmentImpl(Builder builder) {
6062 this .executionStepInfo = builder .executionStepInfo ;
6163 this .dataLoaderRegistry = builder .dataLoaderRegistry ;
6264 this .cacheControl = builder .cacheControl ;
65+ this .locale = builder .locale ;
6366 this .operationDefinition = builder .operationDefinition ;
6467 this .document = builder .document ;
6568 this .variables = builder .variables == null ? Collections .emptyMap () : builder .variables ;
6669 this .queryDirectives = builder .queryDirectives ;
6770 }
6871
72+ /**
73+ * @return a new {@link graphql.schema.DataFetchingEnvironmentImpl.Builder}
74+ */
75+ public static Builder newDataFetchingEnvironment () {
76+ return new Builder ();
77+ }
78+
79+ public static Builder newDataFetchingEnvironment (DataFetchingEnvironment environment ) {
80+ return new Builder ((DataFetchingEnvironmentImpl ) environment );
81+ }
82+
83+ public static Builder newDataFetchingEnvironment (ExecutionContext executionContext ) {
84+ return new Builder ()
85+ .context (executionContext .getContext ())
86+ .root (executionContext .getRoot ())
87+ .graphQLSchema (executionContext .getGraphQLSchema ())
88+ .fragmentsByName (executionContext .getFragmentsByName ())
89+ .dataLoaderRegistry (executionContext .getDataLoaderRegistry ())
90+ .cacheControl (executionContext .getCacheControl ())
91+ .locale (executionContext .getLocale ())
92+ .locale (executionContext .getLocale ())
93+ .document (executionContext .getDocument ())
94+ .operationDefinition (executionContext .getOperationDefinition ())
95+ .variables (executionContext .getVariables ())
96+ .executionId (executionContext .getExecutionId ());
97+ }
98+
6999 @ Override
70100 public <T > T getSource () {
71101 return (T ) source ;
@@ -181,6 +211,11 @@ public CacheControl getCacheControl() {
181211 return cacheControl ;
182212 }
183213
214+ @ Override
215+ public Locale getLocale () {
216+ return locale ;
217+ }
218+
184219 @ Override
185220 public OperationDefinition getOperationDefinition () {
186221 return operationDefinition ;
@@ -203,31 +238,6 @@ public String toString() {
203238 '}' ;
204239 }
205240
206- /**
207- * @return a new {@link graphql.schema.DataFetchingEnvironmentImpl.Builder}
208- */
209- public static Builder newDataFetchingEnvironment () {
210- return new Builder ();
211- }
212-
213- public static Builder newDataFetchingEnvironment (DataFetchingEnvironment environment ) {
214- return new Builder ((DataFetchingEnvironmentImpl ) environment );
215- }
216-
217- public static Builder newDataFetchingEnvironment (ExecutionContext executionContext ) {
218- return new Builder ()
219- .context (executionContext .getContext ())
220- .root (executionContext .getRoot ())
221- .graphQLSchema (executionContext .getGraphQLSchema ())
222- .fragmentsByName (executionContext .getFragmentsByName ())
223- .dataLoaderRegistry (executionContext .getDataLoaderRegistry ())
224- .cacheControl (executionContext .getCacheControl ())
225- .document (executionContext .getDocument ())
226- .operationDefinition (executionContext .getOperationDefinition ())
227- .variables (executionContext .getVariables ())
228- .executionId (executionContext .getExecutionId ());
229- }
230-
231241 public static class Builder {
232242
233243 private Object source ;
@@ -244,6 +254,7 @@ public static class Builder {
244254 private ExecutionStepInfo executionStepInfo ;
245255 private DataLoaderRegistry dataLoaderRegistry ;
246256 private CacheControl cacheControl ;
257+ private Locale locale ;
247258 private OperationDefinition operationDefinition ;
248259 private Document document ;
249260 private Map <String , Object > arguments ;
@@ -268,6 +279,7 @@ public Builder(DataFetchingEnvironmentImpl env) {
268279 this .executionStepInfo = env .executionStepInfo ;
269280 this .dataLoaderRegistry = env .dataLoaderRegistry ;
270281 this .cacheControl = env .cacheControl ;
282+ this .localContext = env .locale ;
271283 this .operationDefinition = env .operationDefinition ;
272284 this .document = env .document ;
273285 this .variables = env .variables ;
@@ -357,6 +369,11 @@ public Builder cacheControl(CacheControl cacheControl) {
357369 return this ;
358370 }
359371
372+ public Builder locale (Locale locale ) {
373+ this .locale = locale ;
374+ return this ;
375+ }
376+
360377 public Builder operationDefinition (OperationDefinition operationDefinition ) {
361378 this .operationDefinition = operationDefinition ;
362379 return this ;
0 commit comments