This repository was archived by the owner on Feb 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed
main/java/graphql/execution
test/groovy/graphql/execution/defer Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 2020import graphql .language .VariableDefinition ;
2121import graphql .schema .GraphQLObjectType ;
2222import graphql .schema .GraphQLSchema ;
23+ import org .reactivestreams .Publisher ;
2324import org .slf4j .Logger ;
2425import org .slf4j .LoggerFactory ;
2526
@@ -179,16 +180,14 @@ private CompletableFuture<ExecutionResult> executeOperation(ExecutionContext exe
179180 */
180181 private CompletableFuture <ExecutionResult > deferSupport (ExecutionContext executionContext , CompletableFuture <ExecutionResult > result ) {
181182 return result .thenApply (er -> {
182- Map <Object , Object > extensions = er .getExtensions ();
183183 DeferSupport deferSupport = executionContext .getDeferSupport ();
184184 if (deferSupport .isDeferDetected ()) {
185- if (extensions == null ) {
186- extensions = new LinkedHashMap <>();
187- }
188185 // we start the rest of the query now to maximize throughput. We have the initial important results
189186 // and now we can start the rest of the calls as early as possible (even before some one subscribes)
190- extensions .put (DeferSupport .DEFERRED_RESULT_STREAM_NAME , deferSupport .startDeferredCalls ());
191- return ExecutionResultImpl .newExecutionResult ().from ((ExecutionResultImpl ) er ).extensions (extensions ).build ();
187+ Publisher <ExecutionResult > publisher = deferSupport .startDeferredCalls ();
188+ return ExecutionResultImpl .newExecutionResult ().from ((ExecutionResultImpl ) er )
189+ .addExtension (DeferSupport .DEFERRED_RESULT_STREAM_NAME , publisher )
190+ .build ();
192191 }
193192 return er ;
194193 });
Original file line number Diff line number Diff line change @@ -175,12 +175,12 @@ class DeferSupportIntegrationTest extends Specification {
175175 Publisher<ExecutionResult > deferredResultStream = initialResult. extensions[" deferredResultStream" ] as Publisher<ExecutionResult >
176176 AtomicBoolean doneORCancelled = new AtomicBoolean ()
177177 def subscriber = new Subscriber<ExecutionResult > () {
178- Subscription subscription;
178+ Subscription subscription
179179
180180 @Override
181181 void onSubscribe (Subscription s ) {
182182 println " \n onSubscribe@" + sentAt()
183- subscription = s;
183+ subscription = s
184184 subscription. request(1 )
185185 }
186186
You can’t perform that action at this time.
0 commit comments