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
142 changes: 0 additions & 142 deletions src/main/java/graphql/execution/AbsoluteGraphQLError.java

This file was deleted.

29 changes: 3 additions & 26 deletions src/main/java/graphql/execution/DataFetcherResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class DataFetcherResult<T> {
private final T data;
private final List<GraphQLError> errors;
private final Object localContext;
private final boolean mapRelativeErrors;

/**
* Creates a data fetcher result
Expand All @@ -43,14 +42,13 @@ public class DataFetcherResult<T> {
@Internal
@Deprecated
public DataFetcherResult(T data, List<GraphQLError> errors) {
this(data, errors, null, false);
this(data, errors, null);
}

private DataFetcherResult(T data, List<GraphQLError> errors, Object localContext, boolean mapRelativeErrors) {
private DataFetcherResult(T data, List<GraphQLError> errors, Object localContext) {
this.data = data;
this.errors = ImmutableList.copyOf(assertNotNull(errors));
this.localContext = localContext;
this.mapRelativeErrors = mapRelativeErrors;
}

/**
Expand Down Expand Up @@ -83,20 +81,6 @@ public Object getLocalContext() {
return localContext;
}

/**
* When this returns true, the data fetching code will map this error as being a relative error from the existing field.
* <p>
* This is useful when you are calling a down stream graphql system and you want to make the errors appear to be from a point
* relative to the currently executing field.
* <p>
* By default this behavior is off
*
* @return true if relative error mapping should occur.
*/
public boolean isMapRelativeErrors() {
return mapRelativeErrors;
}

/**
* This helps you transform the current DataFetcherResult into another one by starting a builder with all
* the current values and allows you to transform it how you want.
Expand Down Expand Up @@ -126,13 +110,11 @@ public static class Builder<T> {
private T data;
private Object localContext;
private final List<GraphQLError> errors = new ArrayList<>();
private boolean mapRelativeErrors = false;

public Builder(DataFetcherResult<T> existing) {
data = existing.getData();
localContext = existing.getLocalContext();
errors.addAll(existing.getErrors());
mapRelativeErrors = existing.isMapRelativeErrors();
}

public Builder(T data) {
Expand All @@ -157,11 +139,6 @@ public Builder<T> error(GraphQLError error) {
return this;
}

public Builder<T> mapRelativeErrors(boolean mapRelativeErrors) {
this.mapRelativeErrors = mapRelativeErrors;
return this;
}

/**
* @return true if there are any errors present
*/
Expand All @@ -175,7 +152,7 @@ public Builder<T> localContext(Object localContext) {
}

public DataFetcherResult<T> build() {
return new DataFetcherResult<>(data, errors, localContext, mapRelativeErrors);
return new DataFetcherResult<>(data, errors, localContext);
}
}
}
11 changes: 3 additions & 8 deletions src/main/java/graphql/execution/ExecutionStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,9 @@ protected FetchedValue unboxPossibleDataFetcherResult(ExecutionContext execution
Object result) {

if (result instanceof DataFetcherResult) {
DataFetcherResult<?> dataFetcherResult = (DataFetcherResult<?>) result;
if (dataFetcherResult.isMapRelativeErrors()) {
dataFetcherResult.getErrors().stream()
.map(relError -> new AbsoluteGraphQLError(parameters, relError))
.forEach(executionContext::addError);
} else {
dataFetcherResult.getErrors().forEach(executionContext::addError);
}
//noinspection unchecked
DataFetcherResult<?> dataFetcherResult = (DataFetcherResult) result;
dataFetcherResult.getErrors().forEach(executionContext::addError);

Object localContext = dataFetcherResult.getLocalContext();
if (localContext == null) {
Expand Down
9 changes: 1 addition & 8 deletions src/main/java/graphql/execution/nextgen/ValueFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import graphql.GraphQLError;
import graphql.Internal;
import graphql.collect.ImmutableKit;
import graphql.execution.AbsoluteGraphQLError;
import graphql.execution.Async;
import graphql.execution.DataFetcherResult;
import graphql.execution.DefaultValueUnboxer;
Expand Down Expand Up @@ -44,7 +43,6 @@
import java.util.concurrent.CompletionStage;
import java.util.function.Supplier;

import static graphql.collect.ImmutableKit.map;
import static graphql.schema.DataFetchingEnvironmentImpl.newDataFetchingEnvironment;
import static java.util.Collections.singletonList;

Expand Down Expand Up @@ -211,13 +209,8 @@ private void handleFetchedValue(Object fetchedValue, CompletableFuture<Object> c
private FetchedValue unboxPossibleDataFetcherResult(MergedField sameField, ResultPath resultPath, FetchedValue result, Object localContext) {
if (result.getFetchedValue() instanceof DataFetcherResult) {

List<GraphQLError> addErrors;
DataFetcherResult<?> dataFetcherResult = (DataFetcherResult) result.getFetchedValue();
if (dataFetcherResult.isMapRelativeErrors()) {
addErrors = map(dataFetcherResult.getErrors(), relError -> new AbsoluteGraphQLError(sameField, resultPath, relError));
} else {
addErrors = ImmutableList.copyOf(dataFetcherResult.getErrors());
}
List<GraphQLError> addErrors = ImmutableList.copyOf(dataFetcherResult.getErrors());
List<GraphQLError> newErrors = ImmutableKit.concatLists(result.getErrors(), addErrors);

Object newLocalContext = dataFetcherResult.getLocalContext();
Expand Down
Loading