Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat(servers): move execution out of reactor netty threads" #2028

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Expedia, Inc
* Copyright 2022 Expedia, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,10 +21,8 @@ import com.expediagroup.graphql.generator.extensions.plus
import com.expediagroup.graphql.server.types.GraphQLResponse
import com.expediagroup.graphql.server.types.GraphQLServerResponse
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.withContext
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext

Expand All @@ -50,20 +48,18 @@ open class GraphQLServer<Request>(
): GraphQLServerResponse? =
coroutineScope {
requestParser.parseRequest(request)?.let { graphQLRequest ->
withContext(Dispatchers.Default) {
val graphQLContext = contextFactory.generateContext(request)
val graphQLContext = contextFactory.generateContext(request)

val customCoroutineContext = (graphQLContext.get<CoroutineContext>() ?: EmptyCoroutineContext)
val graphQLExecutionScope = CoroutineScope(
coroutineContext + customCoroutineContext + SupervisorJob()
)
val customCoroutineContext = (graphQLContext.get<CoroutineContext>() ?: EmptyCoroutineContext)
val graphQLExecutionScope = CoroutineScope(
coroutineContext + customCoroutineContext + SupervisorJob()
)

val graphQLContextWithCoroutineScope = graphQLContext + mapOf(
CoroutineScope::class to graphQLExecutionScope
)
val graphQLContextWithCoroutineScope = graphQLContext + mapOf(
CoroutineScope::class to graphQLExecutionScope
)

requestHandler.executeRequest(graphQLRequest, graphQLContextWithCoroutineScope)
}
requestHandler.executeRequest(graphQLRequest, graphQLContextWithCoroutineScope)
}
}
}
Loading