Skip to content

Commit d204c2b

Browse files
committed
Merge branch 'master' into validation-error-refactor
2 parents a7493b6 + 59679e0 commit d204c2b

18 files changed

Lines changed: 189 additions & 190 deletions

src/main/java/graphql/analysis/NodeVisitorWithTypeTracking.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,12 @@
4343
@Internal
4444
public class NodeVisitorWithTypeTracking extends NodeVisitorStub {
4545

46-
4746
private final QueryVisitor preOrderCallback;
4847
private final QueryVisitor postOrderCallback;
4948
private final Map<String, Object> variables;
5049
private final GraphQLSchema schema;
5150
private final Map<String, FragmentDefinition> fragmentsByName;
52-
5351
private final ConditionalNodes conditionalNodes = new ConditionalNodes();
54-
private final ValuesResolver valuesResolver = new ValuesResolver();
55-
5652

5753
public NodeVisitorWithTypeTracking(QueryVisitor preOrderCallback, QueryVisitor postOrderCallback, Map<String, Object> variables, GraphQLSchema schema, Map<String, FragmentDefinition> fragmentsByName) {
5854
this.preOrderCallback = preOrderCallback;
@@ -155,7 +151,7 @@ public TraversalControl visitField(Field field, TraverserContext<Node> context)
155151
boolean isTypeNameIntrospectionField = fieldDefinition == schema.getIntrospectionTypenameFieldDefinition();
156152
GraphQLFieldsContainer fieldsContainer = !isTypeNameIntrospectionField ? (GraphQLFieldsContainer) unwrapAll(parentEnv.getOutputType()) : null;
157153
GraphQLCodeRegistry codeRegistry = schema.getCodeRegistry();
158-
Map<String, Object> argumentValues = valuesResolver.getArgumentValues(codeRegistry, fieldDefinition.getArguments(), field.getArguments(), CoercedVariables.of(variables));
154+
Map<String, Object> argumentValues = ValuesResolver.getArgumentValues(codeRegistry, fieldDefinition.getArguments(), field.getArguments(), CoercedVariables.of(variables));
159155
QueryVisitorFieldEnvironment environment = new QueryVisitorFieldEnvironmentImpl(isTypeNameIntrospectionField,
160156
field,
161157
fieldDefinition,

src/main/java/graphql/analysis/QueryTraverser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private QueryTraverser(GraphQLSchema schema,
7070
this.fragmentsByName = getOperationResult.fragmentsByName;
7171
this.roots = singletonList(getOperationResult.operationDefinition);
7272
this.rootParentType = getRootTypeFromOperation(getOperationResult.operationDefinition);
73-
this.coercedVariables = new ValuesResolver().coerceVariableValues(schema, variableDefinitions, rawVariables);
73+
this.coercedVariables = ValuesResolver.coerceVariableValues(schema, variableDefinitions, rawVariables);
7474
}
7575

7676
private QueryTraverser(GraphQLSchema schema,

src/main/java/graphql/execution/ConditionalNodes.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import graphql.Assert;
44
import graphql.Internal;
5-
import graphql.VisibleForTesting;
65
import graphql.language.Directive;
76
import graphql.language.NodeUtil;
87

@@ -15,9 +14,6 @@
1514
@Internal
1615
public class ConditionalNodes {
1716

18-
@VisibleForTesting
19-
ValuesResolver valuesResolver = new ValuesResolver();
20-
2117
public boolean shouldInclude(Map<String, Object> variables, List<Directive> directives) {
2218
// shortcut on no directives
2319
if (directives.isEmpty()) {
@@ -34,7 +30,7 @@ public boolean shouldInclude(Map<String, Object> variables, List<Directive> dire
3430
private boolean getDirectiveResult(Map<String, Object> variables, List<Directive> directives, String directiveName, boolean defaultValue) {
3531
Directive foundDirective = NodeUtil.findNodeByName(directives, directiveName);
3632
if (foundDirective != null) {
37-
Map<String, Object> argumentValues = valuesResolver.getArgumentValues(SkipDirective.getArguments(), foundDirective.getArguments(), CoercedVariables.of(variables));
33+
Map<String, Object> argumentValues = ValuesResolver.getArgumentValues(SkipDirective.getArguments(), foundDirective.getArguments(), CoercedVariables.of(variables));
3834
Object flag = argumentValues.get("if");
3935
Assert.assertTrue(flag instanceof Boolean, () -> String.format("The '%s' directive MUST have a value for the 'if' argument", directiveName));
4036
return (Boolean) flag;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public class Execution {
4040
private static final Logger logNotSafe = LogKit.getNotPrivacySafeLogger(Execution.class);
4141

4242
private final FieldCollector fieldCollector = new FieldCollector();
43-
private final ValuesResolver valuesResolver = new ValuesResolver();
4443
private final ExecutionStrategy queryStrategy;
4544
private final ExecutionStrategy mutationStrategy;
4645
private final ExecutionStrategy subscriptionStrategy;
@@ -66,7 +65,7 @@ public CompletableFuture<ExecutionResult> execute(Document document, GraphQLSche
6665

6766
CoercedVariables coercedVariables;
6867
try {
69-
coercedVariables = valuesResolver.coerceVariableValues(graphQLSchema, variableDefinitions, inputVariables);
68+
coercedVariables = ValuesResolver.coerceVariableValues(graphQLSchema, variableDefinitions, inputVariables);
7069
} catch (RuntimeException rte) {
7170
if (rte instanceof GraphQLError) {
7271
return completedFuture(new ExecutionResultImpl((GraphQLError) rte));

src/main/java/graphql/execution/ExecutionStepInfoFactory.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@
1717
@Internal
1818
public class ExecutionStepInfoFactory {
1919

20-
21-
ValuesResolver valuesResolver = new ValuesResolver();
22-
23-
2420
public ExecutionStepInfo newExecutionStepInfoForSubField(ExecutionContext executionContext, MergedField mergedField, ExecutionStepInfo parentInfo) {
2521
GraphQLObjectType parentType = (GraphQLObjectType) parentInfo.getUnwrappedNonNullType();
2622
GraphQLFieldDefinition fieldDefinition = Introspection.getFieldDef(executionContext.getGraphQLSchema(), parentType, mergedField.getName());
2723
GraphQLOutputType fieldType = fieldDefinition.getType();
2824
List<Argument> fieldArgs = mergedField.getArguments();
2925
GraphQLCodeRegistry codeRegistry = executionContext.getGraphQLSchema().getCodeRegistry();
30-
Supplier<Map<String, Object>> argumentValues = FpKit.intraThreadMemoize(() -> valuesResolver.getArgumentValues(codeRegistry, fieldDefinition.getArguments(), fieldArgs, executionContext.getCoercedVariables()));
26+
Supplier<Map<String, Object>> argumentValues = FpKit.intraThreadMemoize(() -> ValuesResolver.getArgumentValues(codeRegistry, fieldDefinition.getArguments(), fieldArgs, executionContext.getCoercedVariables()));
3127

3228
ResultPath newPath = parentInfo.getPath().segment(mergedField.getResultKey());
3329

src/main/java/graphql/execution/ExecutionStrategy.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ public abstract class ExecutionStrategy {
126126
private static final Logger log = LoggerFactory.getLogger(ExecutionStrategy.class);
127127
private static final Logger logNotSafe = LogKit.getNotPrivacySafeLogger(ExecutionStrategy.class);
128128

129-
protected final ValuesResolver valuesResolver = new ValuesResolver();
130129
protected final FieldCollector fieldCollector = new FieldCollector();
131130
protected final ExecutionStepInfoFactory executionStepInfoFactory = new ExecutionStepInfoFactory();
132131
private final ResolveType resolvedType = new ResolveType();
@@ -818,7 +817,7 @@ protected ExecutionStepInfo createExecutionStepInfo(ExecutionContext executionCo
818817
if (!fieldArgDefs.isEmpty()) {
819818
List<Argument> fieldArgs = field.getArguments();
820819
GraphQLCodeRegistry codeRegistry = executionContext.getGraphQLSchema().getCodeRegistry();
821-
argumentValues = FpKit.intraThreadMemoize(() -> valuesResolver.getArgumentValues(codeRegistry, fieldArgDefs, fieldArgs, executionContext.getCoercedVariables()));
820+
argumentValues = FpKit.intraThreadMemoize(() -> ValuesResolver.getArgumentValues(codeRegistry, fieldArgDefs, fieldArgs, executionContext.getCoercedVariables()));
822821
}
823822

824823

0 commit comments

Comments
 (0)