Skip to content

Commit 810582d

Browse files
committed
Stop reading the CoroutineScope from the legacy context object
1 parent a0b56c7 commit 810582d

2 files changed

Lines changed: 3 additions & 18 deletions

File tree

‎src/main/kotlin/graphql/kickstart/tools/util/Utils.kt‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import graphql.schema.idl.TypeUtil
99
import kotlinx.coroutines.CoroutineScope
1010
import kotlinx.coroutines.Dispatchers
1111
import org.apache.commons.lang3.reflect.TypeUtils
12-
import org.slf4j.LoggerFactory
13-
import java.lang.invoke.MethodHandles
1412
import java.lang.reflect.Method
1513
import java.lang.reflect.ParameterizedType
1614
import java.lang.reflect.Proxy
@@ -22,8 +20,6 @@ import kotlin.reflect.jvm.kotlinFunction
2220
* @author Andrew Potter
2321
*/
2422

25-
private val log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass())
26-
2723
internal typealias GraphQLRootResolver = GraphQLResolver<Void>
2824

2925
internal typealias JavaType = java.lang.reflect.Type
@@ -70,17 +66,6 @@ internal fun DataFetchingEnvironment.coroutineScope(): CoroutineScope {
7066
return scope
7167
}
7268

73-
@Suppress("DEPRECATION")
74-
val context: Any? = this.getContext()
75-
if (context is CoroutineScope) {
76-
log.warn(
77-
"Passing a CoroutineScope as the context object has been deprecated by graphql-java. " +
78-
"Please insert it into the GraphQLContext map under the CoroutineScope class key when building the ExecutionInput. " +
79-
"Support for the context object will be removed in the next major release."
80-
)
81-
return context
82-
}
83-
8469
return CoroutineScope(Dispatchers.Default)
8570
}
8671

‎src/test/kotlin/graphql/kickstart/tools/MethodFieldResolverDataFetcherTest.kt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class MethodFieldResolverDataFetcherTest {
9898
}
9999

100100
@Test
101-
fun `data fetcher executes suspend function in CoroutineScope from legacy context`() {
101+
fun `data fetcher does not execute suspend function in CoroutineScope from legacy context`() {
102102
// setup
103103
val scopeClass = ScopeClass()
104104

@@ -107,7 +107,7 @@ class MethodFieldResolverDataFetcherTest {
107107
// expect
108108
@Suppress("UNCHECKED_CAST")
109109
val future = resolver.get(createEnvironment(DataClass(), legacyContext = scopeClass.scope)) as CompletableFuture<Boolean>
110-
assert(future.get())
110+
assertEquals(future.get(), false)
111111
}
112112

113113
class ScopeClass : GraphQLResolver<DataClass> {
@@ -116,7 +116,7 @@ class MethodFieldResolverDataFetcherTest {
116116

117117
@Suppress("UNUSED_PARAMETER")
118118
suspend fun isActive(data: DataClass): Boolean {
119-
return coroutineContext[Job] == job.children.first()
119+
return coroutineContext[Job] == job.children.firstOrNull()
120120
}
121121
}
122122

0 commit comments

Comments
 (0)