From 393bef2889090fd774a4a9165ad1ab03aef8756b Mon Sep 17 00:00:00 2001 From: "$(git --no-pager log --format=format:'%an' -n 1)" Date: Wed, 11 Sep 2024 19:38:28 -0700 Subject: [PATCH 1/2] Fix: Close the scheduled data loader registry upon completion of request. --- .../webflux/DgsWebFluxGraphQLInterceptor.kt | 6 +++++- .../webmvc/DgsWebMvcGraphQLInterceptor.kt | 14 +++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webflux/DgsWebFluxGraphQLInterceptor.kt b/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webflux/DgsWebFluxGraphQLInterceptor.kt index c340834b5..c40239baa 100644 --- a/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webflux/DgsWebFluxGraphQLInterceptor.kt +++ b/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webflux/DgsWebFluxGraphQLInterceptor.kt @@ -60,6 +60,10 @@ class DgsWebFluxGraphQLInterceptor( .build() } graphQLContextFuture.complete(request.toExecutionInput().graphQLContext) - chain.next(request) + chain.next(request).doFinally { + if (dataLoaderRegistry is AutoCloseable) { + dataLoaderRegistry.close() + } + } } } diff --git a/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt b/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt index 4f4327922..df06d1569 100644 --- a/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt +++ b/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt @@ -67,11 +67,19 @@ class DgsWebMvcGraphQLInterceptor( } graphQLContextFuture.complete(request.toExecutionInput().graphQLContext) - return if (dgsSpringConfigurationProperties.webmvc.asyncdispatch.enabled) { - chain.next(request) + return if (dgsSpringConfigurationProperties.webmvc.asyncdispatch.enabled) { + chain.next(request).doFinally { + if (dataLoaderRegistry is AutoCloseable) { + dataLoaderRegistry.close() + } + } } else { @Suppress("BlockingMethodInNonBlockingContext") - return Mono.just(chain.next(request).block()!!) + val response = chain.next(request).block()!! + if(dataLoaderRegistry is AutoCloseable) { + dataLoaderRegistry.close() + } + return Mono.just(response) } } } From 5586e4da89ff1d7605590605cc70a73aff1fa462 Mon Sep 17 00:00:00 2001 From: "$(git --no-pager log --format=format:'%an' -n 1)" Date: Wed, 11 Sep 2024 20:14:25 -0700 Subject: [PATCH 2/2] fix lint warnings. --- .../dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt b/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt index df06d1569..174038801 100644 --- a/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt +++ b/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt @@ -67,7 +67,7 @@ class DgsWebMvcGraphQLInterceptor( } graphQLContextFuture.complete(request.toExecutionInput().graphQLContext) - return if (dgsSpringConfigurationProperties.webmvc.asyncdispatch.enabled) { + return if (dgsSpringConfigurationProperties.webmvc.asyncdispatch.enabled) { chain.next(request).doFinally { if (dataLoaderRegistry is AutoCloseable) { dataLoaderRegistry.close() @@ -76,7 +76,7 @@ class DgsWebMvcGraphQLInterceptor( } else { @Suppress("BlockingMethodInNonBlockingContext") val response = chain.next(request).block()!! - if(dataLoaderRegistry is AutoCloseable) { + if (dataLoaderRegistry is AutoCloseable) { dataLoaderRegistry.close() } return Mono.just(response)