Skip to content

Commit

Permalink
Fix: Close the scheduled data loader registry upon completion of requ…
Browse files Browse the repository at this point in the history
…est.
  • Loading branch information
srinivasankavitha committed Sep 12, 2024
1 parent 3004820 commit 393bef2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

0 comments on commit 393bef2

Please sign in to comment.