diff --git a/src/main/java/graphql/execution/instrumentation/ChainedInstrumentation.java b/src/main/java/graphql/execution/instrumentation/ChainedInstrumentation.java index 1768a80a1a..c8df52365d 100644 --- a/src/main/java/graphql/execution/instrumentation/ChainedInstrumentation.java +++ b/src/main/java/graphql/execution/instrumentation/ChainedInstrumentation.java @@ -263,6 +263,10 @@ public void onFieldValuesInfo(List fieldValueInfoList) { contexts.forEach(context -> context.onFieldValuesInfo(fieldValueInfoList)); } + @Override + public void onFieldValuesException() { + contexts.forEach(ExecutionStrategyInstrumentationContext::onFieldValuesException); + } } } diff --git a/src/test/groovy/graphql/Issue2068.groovy b/src/test/groovy/graphql/Issue2068.groovy index e9869119f8..a111e425d1 100644 --- a/src/test/groovy/graphql/Issue2068.groovy +++ b/src/test/groovy/graphql/Issue2068.groovy @@ -1,5 +1,6 @@ package graphql +import graphql.execution.instrumentation.ChainedInstrumentation import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation import graphql.schema.DataFetcher import graphql.schema.DataFetchingEnvironment @@ -11,6 +12,7 @@ import org.dataloader.DataLoader import org.dataloader.DataLoaderOptions import org.dataloader.DataLoaderRegistry import spock.lang.Specification +import spock.lang.Timeout import java.util.concurrent.CompletableFuture import java.util.concurrent.CompletionStage @@ -119,7 +121,40 @@ class Issue2068 extends Specification { """) .build()) - then: "execution shouldn't hang" + then: "execution with single instrumentation shouldn't hang" + // wait for each future to complete and grab the results + thrown(RuntimeException) + + when: + graphql = GraphQL.newGraphQL(schema) + .instrumentation(new ChainedInstrumentation( + Collections.singletonList(new DataLoaderDispatcherInstrumentation())) + ) + .build() + + graphql.execute(newExecutionInput() + .dataLoaderRegistry(dataLoaderRegistry) + .query(""" + query LoadPets { + pets { + cats { + toys { + name + } + } + dogs { + owner { + nation { + name + } + } + } + } + } + """) + .build()) + + then: "execution with chained instrumentation shouldn't hang" // wait for each future to complete and grab the results thrown(RuntimeException) }