Skip to content

Commit 6d5e7d9

Browse files
committed
change TypeResolutionParameters.field to MergedFields
1 parent 2ae81f2 commit 6d5e7d9

7 files changed

Lines changed: 21 additions & 20 deletions

File tree

‎src/main/java/graphql/TypeResolutionEnvironment.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package graphql;
22

3-
import graphql.language.Field;
3+
import graphql.execution.MergedFields;
44
import graphql.schema.GraphQLSchema;
55
import graphql.schema.GraphQLType;
66

@@ -16,12 +16,12 @@ public class TypeResolutionEnvironment {
1616

1717
private final Object object;
1818
private final Map<String, Object> arguments;
19-
private final Field field;
19+
private final MergedFields field;
2020
private final GraphQLType fieldType;
2121
private final GraphQLSchema schema;
2222
private final Object context;
2323

24-
public TypeResolutionEnvironment(Object object, Map<String, Object> arguments, Field field, GraphQLType fieldType, GraphQLSchema schema, final Object context) {
24+
public TypeResolutionEnvironment(Object object, Map<String, Object> arguments, MergedFields field, GraphQLType fieldType, GraphQLSchema schema, final Object context) {
2525
this.object = object;
2626
this.arguments = arguments;
2727
this.field = field;
@@ -52,7 +52,7 @@ public Map<String, Object> getArguments() {
5252
/**
5353
* @return the graphql field in question
5454
*/
55-
public Field getField() {
55+
public MergedFields getField() {
5656
return field;
5757
}
5858

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ protected Iterable<Object> toIterable(Object result) {
651651
}
652652

653653
protected GraphQLObjectType resolveType(ExecutionContext executionContext, ExecutionStrategyParameters parameters, GraphQLType fieldType) {
654-
return resolvedType.resolveType(executionContext, parameters.getField().getSingleField(), parameters.getSource(), parameters.getArguments(), fieldType);
654+
return resolvedType.resolveType(executionContext, parameters.getField(), parameters.getSource(), parameters.getArguments(), fieldType);
655655
}
656656

657657

‎src/main/java/graphql/execution/ResolveType.java‎

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

33
import graphql.Internal;
44
import graphql.TypeResolutionEnvironment;
5-
import graphql.language.Field;
65
import graphql.schema.GraphQLInterfaceType;
76
import graphql.schema.GraphQLObjectType;
87
import graphql.schema.GraphQLType;
@@ -15,7 +14,7 @@
1514
public class ResolveType {
1615

1716

18-
public GraphQLObjectType resolveType(ExecutionContext executionContext, Field field, Object source, Map<String, Object> arguments, GraphQLType fieldType) {
17+
public GraphQLObjectType resolveType(ExecutionContext executionContext, MergedFields field, Object source, Map<String, Object> arguments, GraphQLType fieldType) {
1918
GraphQLObjectType resolvedType;
2019
if (fieldType instanceof GraphQLInterfaceType) {
2120
TypeResolutionParameters resolutionParams = TypeResolutionParameters.newParameters()

‎src/main/java/graphql/execution/TypeResolutionParameters.java‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
package graphql.execution;
22

3-
import graphql.language.Field;
3+
import graphql.PublicApi;
44
import graphql.schema.GraphQLInterfaceType;
55
import graphql.schema.GraphQLSchema;
66
import graphql.schema.GraphQLUnionType;
77

88
import java.util.Map;
99

10+
@PublicApi
1011
public class TypeResolutionParameters {
1112

1213
private final GraphQLInterfaceType graphQLInterfaceType;
1314
private final GraphQLUnionType graphQLUnionType;
14-
private final Field field;
15+
private final MergedFields field;
1516
private final Object value;
1617
private final Map<String, Object> argumentValues;
1718
private final GraphQLSchema schema;
1819
private final Object context;
1920

2021
private TypeResolutionParameters(GraphQLInterfaceType graphQLInterfaceType, GraphQLUnionType graphQLUnionType,
21-
Field field, Object value, Map<String, Object> argumentValues, GraphQLSchema schema, final Object context) {
22+
MergedFields field, Object value, Map<String, Object> argumentValues, GraphQLSchema schema, final Object context) {
2223
this.graphQLInterfaceType = graphQLInterfaceType;
2324
this.graphQLUnionType = graphQLUnionType;
2425
this.field = field;
@@ -36,7 +37,7 @@ public GraphQLUnionType getGraphQLUnionType() {
3637
return graphQLUnionType;
3738
}
3839

39-
public Field getField() {
40+
public MergedFields getField() {
4041
return field;
4142
}
4243

@@ -62,15 +63,15 @@ public Object getContext() {
6263

6364
public static class Builder {
6465

65-
private Field field;
66+
private MergedFields field;
6667
private GraphQLInterfaceType graphQLInterfaceType;
6768
private GraphQLUnionType graphQLUnionType;
6869
private Object value;
6970
private Map<String, Object> argumentValues;
7071
private GraphQLSchema schema;
7172
private Object context;
7273

73-
public Builder field(Field field) {
74+
public Builder field(MergedFields field) {
7475
this.field = field;
7576
return this;
7677
}

‎src/main/java/graphql/execution/batched/BatchedExecutionStrategy.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import graphql.execution.instrumentation.parameters.InstrumentationExecutionStrategyParameters;
2424
import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchParameters;
2525
import graphql.execution.instrumentation.parameters.InstrumentationFieldParameters;
26-
import graphql.language.Field;
2726
import graphql.schema.DataFetcher;
2827
import graphql.schema.DataFetchingEnvironment;
2928
import graphql.schema.DataFetchingFieldSelectionSet;
@@ -401,7 +400,7 @@ private List<ExecutionNode> handleObject(ExecutionContext executionContext, Map<
401400
}
402401
MapOrList childResult = mapOrList.createAndPutMap(fieldName);
403402

404-
GraphQLObjectType resolvedType = getGraphQLObjectType(executionContext, fields.getSingleField(), executionStepInfo.getUnwrappedNonNullType(), value.getValue(), argumentValues);
403+
GraphQLObjectType resolvedType = getGraphQLObjectType(executionContext, fields, executionStepInfo.getUnwrappedNonNullType(), value.getValue(), argumentValues);
405404
resultsByType.putIfAbsent(resolvedType, new ArrayList<>());
406405
resultsByType.get(resolvedType).add(childResult);
407406

@@ -446,7 +445,7 @@ private Map<String, MergedFields> getChildFields(ExecutionContext executionConte
446445
return fieldCollector.collectFields(collectorParameters, fields);
447446
}
448447

449-
private GraphQLObjectType getGraphQLObjectType(ExecutionContext executionContext, Field field, GraphQLType fieldType, Object value, Map<String, Object> argumentValues) {
448+
private GraphQLObjectType getGraphQLObjectType(ExecutionContext executionContext, MergedFields field, GraphQLType fieldType, Object value, Map<String, Object> argumentValues) {
450449
return resolveType.resolveType(executionContext, field, value, argumentValues, fieldType);
451450
}
452451

‎src/main/java/graphql/execution/nextgen/FetchedValueAnalyzer.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private FetchedValueAnalysis analyzeFetchedValueImpl(FetchedValue fetchedValue,
8686
.nullValue()
8787
.build();
8888
}
89-
resolvedObjectType = resolveType.resolveType(executionContext, field.getSingleField(), toAnalyze, executionInfo.getArguments(), fieldType);
89+
resolvedObjectType = resolveType.resolveType(executionContext, field, toAnalyze, executionInfo.getArguments(), fieldType);
9090
return analyzeObject(fetchedValue, toAnalyze, name, resolvedObjectType, executionInfo);
9191
} catch (UnresolvedTypeException ex) {
9292
return handleUnresolvedTypeProblem(fetchedValue, name, executionInfo, ex);

‎src/test/groovy/graphql/TypeResolutionEnvironmentTest.groovy‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import graphql.schema.GraphQLObjectType
55
import graphql.schema.TypeResolver
66
import spock.lang.Specification
77

8+
import static graphql.TestUtil.mergedFields
9+
810
class TypeResolutionEnvironmentTest extends Specification {
911

1012
def idl = """
@@ -37,7 +39,7 @@ class TypeResolutionEnvironmentTest extends Specification {
3739
def "basic operations"() {
3840
given:
3941

40-
def environment = new TypeResolutionEnvironment("source", [:], new Field("field"), Scalars.GraphQLString, schema, "FooBar")
42+
def environment = new TypeResolutionEnvironment("source", [:], mergedFields(new Field("field")), Scalars.GraphQLString, schema, "FooBar")
4143

4244
when:
4345

@@ -91,14 +93,14 @@ class TypeResolutionEnvironmentTest extends Specification {
9193
}
9294

9395
when:
94-
def environmentFooBar = new TypeResolutionEnvironment("source", [:], new Field("field"), Scalars.GraphQLString, schema, "FooBar")
96+
def environmentFooBar = new TypeResolutionEnvironment("source", [:], mergedFields(new Field("field")), Scalars.GraphQLString, schema, "FooBar")
9597
def objTypeFooBar = resolverWithContext.getType(environmentFooBar)
9698

9799
then:
98100
objTypeFooBar.name == "FooBar"
99101

100102
when:
101-
def environmentFooImpl = new TypeResolutionEnvironment("source", [:], new Field("field"), Scalars.GraphQLString, schema, "Foo")
103+
def environmentFooImpl = new TypeResolutionEnvironment("source", [:], mergedFields(new Field("field")), Scalars.GraphQLString, schema, "Foo")
102104
def objTypeFooImpl = resolverWithContext.getType(environmentFooImpl)
103105

104106
then:

0 commit comments

Comments
 (0)