Skip to content
Merged
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
15 changes: 8 additions & 7 deletions src/main/java/graphql/execution/ExecutionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
import graphql.schema.GraphQLSchema;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;

Expand All @@ -35,6 +37,7 @@ public class ExecutionContext {
private final Object context;
private final Instrumentation instrumentation;
private final List<GraphQLError> errors = new CopyOnWriteArrayList<>();
private final Set<ExecutionPath> errorPaths = new HashSet<>();
private final DeferSupport deferSupport = new DeferSupport();

public ExecutionContext(Instrumentation instrumentation, ExecutionId executionId, GraphQLSchema graphQLSchema, InstrumentationState instrumentationState, ExecutionStrategy queryStrategy, ExecutionStrategy mutationStrategy, ExecutionStrategy subscriptionStrategy, Map<String, FragmentDefinition> fragmentsByName, Document document, OperationDefinition operationDefinition, Map<String, Object> variables, Object context, Object root) {
Expand Down Expand Up @@ -116,13 +119,8 @@ public void addError(GraphQLError error, ExecutionPath fieldPath) {
// field errors should be handled - ie only once per field if its already there for nullability
// but unclear if its not that error path
//
for (GraphQLError graphQLError : errors) {
List<Object> path = graphQLError.getPath();
if (path != null) {
if (fieldPath.equals(ExecutionPath.fromList(path))) {
return;
}
}
if (!errorPaths.add(fieldPath)) {
return;
}
this.errors.add(error);
}
Expand All @@ -137,6 +135,9 @@ public void addError(GraphQLError error) {
// see https://github.com/graphql-java/graphql-java/issues/888 on how the spec is unclear
// on how exactly multiple errors should be handled - ie only once per field or not outside the nullability
// aspect.
if (error.getPath() != null) {
this.errorPaths.add(ExecutionPath.fromList(error.getPath()));
}
this.errors.add(error);
}

Expand Down