Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions src/main/java/graphql/execution/Async.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,33 +126,6 @@ public static <T> CompletableFuture<T> exceptionallyCompletedFuture(Throwable ex
return result;
}

public static <T> void copyResults(CompletableFuture<T> source, CompletableFuture<T> target) {
source.whenComplete((o, throwable) -> {
if (throwable != null) {
target.completeExceptionally(throwable);
return;
}
target.complete(o);
});
}


public static <U, T> CompletableFuture<U> reduce(List<CompletableFuture<T>> values, U initialValue, BiFunction<U, T, U> aggregator) {
CompletableFuture<U> result = new CompletableFuture<>();
reduceImpl(values, 0, initialValue, aggregator, result);
return result;
}

public static <U, T> CompletableFuture<U> reduce(CompletableFuture<List<T>> values, U initialValue, BiFunction<U, T, U> aggregator) {
return values.thenApply(list -> {
U result = initialValue;
for (T value : list) {
result = aggregator.apply(result, value);
}
return result;
});
}

public static <U, T> CompletableFuture<List<U>> flatMap(List<T> inputs, Function<T, CompletableFuture<U>> mapper) {
List<CompletableFuture<U>> collect = inputs
.stream()
Expand All @@ -161,16 +134,6 @@ public static <U, T> CompletableFuture<List<U>> flatMap(List<T> inputs, Function
return Async.each(collect);
}

private static <U, T> void reduceImpl(List<CompletableFuture<T>> values, int curIndex, U curValue, BiFunction<U, T, U> aggregator, CompletableFuture<U> result) {
if (curIndex == values.size()) {
result.complete(curValue);
return;
}
values.get(curIndex).
thenApply(oneValue -> aggregator.apply(curValue, oneValue))
.thenAccept(newValue -> reduceImpl(values, curIndex + 1, newValue, aggregator, result));
}

public static <U, T> CompletableFuture<List<U>> map(CompletableFuture<List<T>> values, Function<T, U> mapper) {
return values.thenApply(list -> list.stream().map(mapper).collect(Collectors.toList()));
}
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/graphql/execution/ExecutionStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,6 @@ protected CompletableFuture<FieldValueInfo> resolveFieldWithInfo(ExecutionContex
return result;
}

protected CompletableFuture<FieldValueInfo> resolveFieldWithInfoToNull(ExecutionContext executionContext, ExecutionStrategyParameters parameters) {
FetchedValue fetchedValue = FetchedValue.newFetchedValue().build();
FieldValueInfo fieldValueInfo = completeField(executionContext, parameters, fetchedValue);
return CompletableFuture.completedFuture(fieldValueInfo);
}


/**
* Called to fetch a value for a field from the {@link DataFetcher} associated with the field
* {@link GraphQLFieldDefinition}.
Expand Down