Skip to content

Commit d05d13e

Browse files
samuelAndalonSamuel Vazquez
and
Samuel Vazquez
authored
6.x.x revert context switching (#2030)
Co-authored-by: Samuel Vazquez <[email protected]>
1 parent 2388c4a commit d05d13e

File tree

1 file changed

+11
-15
lines changed
  • servers/graphql-kotlin-server/src/main/kotlin/com/expediagroup/graphql/server/execution

1 file changed

+11
-15
lines changed

servers/graphql-kotlin-server/src/main/kotlin/com/expediagroup/graphql/server/execution/GraphQLServer.kt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ package com.expediagroup.graphql.server.execution
1919
import com.expediagroup.graphql.server.types.GraphQLResponse
2020
import com.expediagroup.graphql.server.types.GraphQLServerResponse
2121
import kotlinx.coroutines.CoroutineScope
22-
import kotlinx.coroutines.Dispatchers
2322
import kotlinx.coroutines.SupervisorJob
2423
import kotlinx.coroutines.coroutineScope
25-
import kotlinx.coroutines.withContext
2624
import kotlin.coroutines.CoroutineContext
2725
import kotlin.coroutines.EmptyCoroutineContext
2826

@@ -48,21 +46,19 @@ open class GraphQLServer<Request>(
4846
): GraphQLServerResponse? =
4947
coroutineScope {
5048
requestParser.parseRequest(request)?.let { graphQLRequest ->
51-
withContext(Dispatchers.Default) {
52-
val deprecatedContext = contextFactory.generateContext(request)
53-
val contextMap = contextFactory.generateContextMap(request)
49+
val deprecatedContext = contextFactory.generateContext(request)
50+
val contextMap = contextFactory.generateContextMap(request)
5451

55-
val customCoroutineContext = (deprecatedContext?.graphQLCoroutineContext() ?: EmptyCoroutineContext) +
56-
(contextMap[CoroutineContext::class] as? CoroutineContext ?: EmptyCoroutineContext)
57-
val graphQLExecutionScope = CoroutineScope(
58-
coroutineContext + customCoroutineContext + SupervisorJob()
59-
)
60-
val graphQLContext = contextMap + mapOf(
61-
CoroutineScope::class to graphQLExecutionScope
62-
)
52+
val customCoroutineContext = (deprecatedContext?.graphQLCoroutineContext() ?: EmptyCoroutineContext) +
53+
(contextMap[CoroutineContext::class] as? CoroutineContext ?: EmptyCoroutineContext)
54+
val graphQLExecutionScope = CoroutineScope(
55+
coroutineContext + customCoroutineContext + SupervisorJob()
56+
)
57+
val graphQLContext = contextMap + mapOf(
58+
CoroutineScope::class to graphQLExecutionScope
59+
)
6360

64-
requestHandler.executeRequest(graphQLRequest, deprecatedContext, graphQLContext)
65-
}
61+
requestHandler.executeRequest(graphQLRequest, deprecatedContext, graphQLContext)
6662
}
6763
}
6864
}

0 commit comments

Comments
 (0)