Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Commit 7d318d7

Browse files
committed
Improved builder usage
1 parent e187e36 commit 7d318d7

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/main/java/graphql/execution/Execution.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import graphql.language.VariableDefinition;
2121
import graphql.schema.GraphQLObjectType;
2222
import graphql.schema.GraphQLSchema;
23+
import org.reactivestreams.Publisher;
2324
import org.slf4j.Logger;
2425
import 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
});

src/test/groovy/graphql/execution/defer/DeferSupportIntegrationTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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 "\nonSubscribe@" + sentAt()
183-
subscription = s;
183+
subscription = s
184184
subscription.request(1)
185185
}
186186

0 commit comments

Comments
 (0)