@@ -25,24 +25,26 @@ class ExecutionContextBuilderTest extends Specification {
2525 def operation = document. definitions[0 ] as OperationDefinition
2626 def fragment = document. definitions[1 ] as FragmentDefinition
2727 def dataLoaderRegistry = new DataLoaderRegistry ()
28+ def mockDataLoaderDispatcherStrategy = Mock (DataLoaderDispatchStrategy )
2829
2930 def " builds the correct ExecutionContext" () {
3031 when :
3132 def executionContext = new ExecutionContextBuilder ()
32- .instrumentation(instrumentation)
33- .queryStrategy(queryStrategy)
34- .mutationStrategy(mutationStrategy)
35- .subscriptionStrategy(subscriptionStrategy)
36- .graphQLSchema(schema)
37- .executionId(executionId)
38- .context(context) // Retain deprecated builder for test coverage
39- .graphQLContext(graphQLContext)
40- .root(root)
41- .operationDefinition(operation)
42- .fragmentsByName([MyFragment : fragment])
43- .variables([var : ' value' ]) // Retain deprecated builder for test coverage
44- .dataLoaderRegistry(dataLoaderRegistry)
45- .build()
33+ .instrumentation(instrumentation)
34+ .queryStrategy(queryStrategy)
35+ .mutationStrategy(mutationStrategy)
36+ .subscriptionStrategy(subscriptionStrategy)
37+ .graphQLSchema(schema)
38+ .executionId(executionId)
39+ .context(context) // Retain deprecated builder for test coverage
40+ .graphQLContext(graphQLContext)
41+ .root(root)
42+ .operationDefinition(operation)
43+ .fragmentsByName([MyFragment : fragment])
44+ .variables([var : ' value' ]) // Retain deprecated builder for test coverage
45+ .dataLoaderRegistry(dataLoaderRegistry)
46+ .dataLoaderDispatcherStrategy(mockDataLoaderDispatcherStrategy)
47+ .build()
4648
4749 then :
4850 executionContext. executionId == executionId
@@ -58,6 +60,7 @@ class ExecutionContextBuilderTest extends Specification {
5860 executionContext. getFragmentsByName() == [MyFragment : fragment]
5961 executionContext. operationDefinition == operation
6062 executionContext. dataLoaderRegistry == dataLoaderRegistry
63+ executionContext. dataLoaderDispatcherStrategy == mockDataLoaderDispatcherStrategy
6164 }
6265
6366 def " builds the correct ExecutionContext with coerced variables" () {
@@ -66,19 +69,19 @@ class ExecutionContextBuilderTest extends Specification {
6669
6770 when :
6871 def executionContext = new ExecutionContextBuilder ()
69- .instrumentation(instrumentation)
70- .queryStrategy(queryStrategy)
71- .mutationStrategy(mutationStrategy)
72- .subscriptionStrategy(subscriptionStrategy)
73- .graphQLSchema(schema)
74- .executionId(executionId)
75- .graphQLContext(graphQLContext)
76- .root(root)
77- .operationDefinition(operation)
78- .fragmentsByName([MyFragment : fragment])
79- .coercedVariables(coercedVariables)
80- .dataLoaderRegistry(dataLoaderRegistry)
81- .build()
72+ .instrumentation(instrumentation)
73+ .queryStrategy(queryStrategy)
74+ .mutationStrategy(mutationStrategy)
75+ .subscriptionStrategy(subscriptionStrategy)
76+ .graphQLSchema(schema)
77+ .executionId(executionId)
78+ .graphQLContext(graphQLContext)
79+ .root(root)
80+ .operationDefinition(operation)
81+ .fragmentsByName([MyFragment : fragment])
82+ .coercedVariables(coercedVariables)
83+ .dataLoaderRegistry(dataLoaderRegistry)
84+ .build()
8285
8386 then :
8487 executionContext. executionId == executionId
@@ -205,4 +208,32 @@ class ExecutionContextBuilderTest extends Specification {
205208 executionContext. operationDefinition == operation
206209 executionContext. dataLoaderRegistry == dataLoaderRegistry
207210 }
211+
212+ def " transform copies dispatcher" () {
213+ given :
214+ def oldCoercedVariables = CoercedVariables . emptyVariables()
215+ def executionContextOld = new ExecutionContextBuilder ()
216+ .instrumentation(instrumentation)
217+ .queryStrategy(queryStrategy)
218+ .mutationStrategy(mutationStrategy)
219+ .subscriptionStrategy(subscriptionStrategy)
220+ .graphQLSchema(schema)
221+ .executionId(executionId)
222+ .graphQLContext(graphQLContext)
223+ .root(root)
224+ .operationDefinition(operation)
225+ .coercedVariables(oldCoercedVariables)
226+ .fragmentsByName([MyFragment : fragment])
227+ .dataLoaderRegistry(dataLoaderRegistry)
228+ .dataLoaderDispatcherStrategy(DataLoaderDispatchStrategy . NO_OP )
229+ .build()
230+
231+ when :
232+ def executionContext = executionContextOld
233+ .transform(builder -> builder
234+ .dataLoaderDispatcherStrategy(mockDataLoaderDispatcherStrategy))
235+
236+ then :
237+ executionContext. getDataLoaderDispatcherStrategy() == mockDataLoaderDispatcherStrategy
238+ }
208239}
0 commit comments