Skip to content

Commit

Permalink
Merge pull request #2007 from Netflix/kavitha/fix-scheduled-dataloaders
Browse files Browse the repository at this point in the history
Fix: Close the scheduled data loader registry upon completion of request
  • Loading branch information
srinivasankavitha authored Sep 12, 2024
2 parents 3004820 + 5586e4d commit 2942c51
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 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 @@ -68,10 +68,18 @@ class DgsWebMvcGraphQLInterceptor(
graphQLContextFuture.complete(request.toExecutionInput().graphQLContext)

return if (dgsSpringConfigurationProperties.webmvc.asyncdispatch.enabled) {
chain.next(request)
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 2942c51

Please sign in to comment.