Skip to content

Commit 0f19b69

Browse files
committed
delete legacy resolve field method
1 parent 4c17673 commit 0f19b69

2 files changed

Lines changed: 5 additions & 54 deletions

File tree

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -339,33 +339,6 @@ DeferredExecutionSupport createDeferredExecutionSupport(ExecutionContext executi
339339
return futures;
340340
}
341341

342-
/**
343-
* Called to fetch a value for a field and resolve it further in terms of the graphql query. This will call
344-
* #fetchField followed by #completeField and the completed Object is returned.
345-
* <p>
346-
* An execution strategy can iterate the fields to be executed and call this method for each one
347-
* <p>
348-
* Graphql fragments mean that for any give logical field can have one or more {@link Field} values associated with it
349-
* in the query, hence the fieldList. However, the first entry is representative of the field for most purposes.
350-
*
351-
* @param executionContext contains the top level execution parameters
352-
* @param parameters contains the parameters holding the fields to be executed and source object
353-
*
354-
* @return a {@link CompletableFuture} promise to an {@link Object} or the materialized {@link Object}
355-
*
356-
* @throws NonNullableFieldWasNullException in the future if a non-null field resolved to a null value
357-
*/
358-
@SuppressWarnings("unchecked")
359-
@DuckTyped(shape = " CompletableFuture<Object> | Object")
360-
protected Object resolveField(ExecutionContext executionContext, ExecutionStrategyParameters parameters) {
361-
Object fieldWithInfo = resolveFieldWithInfo(executionContext, parameters);
362-
if (fieldWithInfo instanceof CompletableFuture) {
363-
return ((CompletableFuture<FieldValueInfo>) fieldWithInfo).thenCompose(FieldValueInfo::getFieldValueFuture);
364-
} else {
365-
return ((FieldValueInfo) fieldWithInfo).getFieldValueObject();
366-
}
367-
}
368-
369342
/**
370343
* Called to fetch a value for a field and its extra runtime info and resolve it further in terms of the graphql query. This will call
371344
* #fetchField followed by #completeField and the completed {@link graphql.execution.FieldValueInfo} is returned.

src/test/groovy/graphql/execution/ExecutionStrategyTest.groovy

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ class ExecutionStrategyTest extends Specification {
541541
DataFetchingEnvironment environment
542542

543543
when:
544-
executionStrategy.resolveField(executionContext, parameters)
544+
executionStrategy.resolveFieldWithInfo(executionContext, parameters)
545545

546546
then:
547547
1 * dataFetcher.get(_,_,_) >> { environment = (it[2] as Supplier<DataFetchingEnvironment>).get() }
@@ -636,7 +636,7 @@ class ExecutionStrategyTest extends Specification {
636636
}
637637

638638
when:
639-
overridingStrategy.resolveField(executionContext, parameters)
639+
overridingStrategy.resolveFieldWithInfo(executionContext, parameters)
640640

641641
then:
642642
handlerCalled == true
@@ -646,29 +646,6 @@ class ExecutionStrategyTest extends Specification {
646646
exceptionWhileDataFetching.getMessage().contains('This is the exception you are looking for')
647647
}
648648

649-
def "test that the old legacy method is still useful for those who derive new execution strategies"() {
650-
651-
def expectedException = new UnsupportedOperationException("This is the exception you are looking for")
652-
653-
//noinspection GroovyAssignabilityCheck,GroovyUnusedAssignment
654-
def (ExecutionContext executionContext, GraphQLFieldDefinition fieldDefinition, ResultPath expectedPath, ExecutionStrategyParameters parameters, Field field, SourceLocation sourceLocation) = exceptionSetupFixture(expectedException)
655-
656-
657-
ExecutionStrategy overridingStrategy = new ExecutionStrategy() {
658-
@Override
659-
CompletableFuture<ExecutionResult> execute(ExecutionContext ec, ExecutionStrategyParameters p) throws NonNullableFieldWasNullException {
660-
null
661-
}
662-
}
663-
664-
when:
665-
overridingStrategy.resolveField(executionContext, parameters)
666-
667-
then:
668-
executionContext.errors.size() == 1
669-
def exceptionWhileDataFetching = executionContext.errors[0] as ExceptionWhileDataFetching
670-
exceptionWhileDataFetching.getMessage().contains('This is the exception you are looking for')
671-
}
672649

673650
def "#2519 data fetcher errors for a given field appear in FetchedResult within instrumentation"() {
674651
def expectedException = new UnsupportedOperationException("This is the exception you are looking for")
@@ -700,7 +677,7 @@ class ExecutionStrategyTest extends Specification {
700677
}
701678

702679
when:
703-
overridingStrategy.resolveField(instrumentedExecutionContext, params)
680+
overridingStrategy.resolveFieldWithInfo(instrumentedExecutionContext, params)
704681

705682
then:
706683
FetchedValue fetchedValue = instrumentation.fetchedValues.get("someField")
@@ -761,7 +738,8 @@ class ExecutionStrategyTest extends Specification {
761738
.build()
762739

763740
when:
764-
executionStrategy.resolveField(executionContext, parameters).join()
741+
FieldValueInfo fieldValueInfo = (executionStrategy.resolveFieldWithInfo(executionContext, parameters) as CompletableFuture).join()
742+
(fieldValueInfo.fieldValueObject as CompletableFuture).join()
765743

766744
then:
767745
thrown(CompletionException)

0 commit comments

Comments
 (0)