Skip to content

Commit a628237

Browse files
committed
changed default CoroutineScope to not use GlobalScope to avoid potential cancellation issues and other pitfalls
1 parent b9d4b12 commit a628237

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/main/kotlin/com/coxautodev/graphql/tools/MethodFieldResolver.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import graphql.language.TypeName
1313
import graphql.schema.DataFetcher
1414
import graphql.schema.DataFetchingEnvironment
1515
import graphql.schema.GraphQLTypeUtil.*
16-
import kotlinx.coroutines.GlobalScope
1716
import kotlinx.coroutines.future.future
1817
import java.lang.reflect.Method
1918
import java.util.Comparator

src/main/kotlin/com/coxautodev/graphql/tools/Utils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import graphql.language.ObjectTypeExtensionDefinition
88
import graphql.language.Type
99
import graphql.schema.DataFetchingEnvironment
1010
import kotlinx.coroutines.CoroutineScope
11-
import kotlinx.coroutines.GlobalScope
11+
import kotlinx.coroutines.Dispatchers
1212
import java.lang.reflect.Method
1313
import java.lang.reflect.ParameterizedType
1414
import java.lang.reflect.Proxy
@@ -44,7 +44,7 @@ internal fun JavaType.unwrap(): Class<out Any> =
4444

4545
internal fun DataFetchingEnvironment.coroutineScope(): CoroutineScope {
4646
val context: Any? = this.getContext()
47-
return if (context is CoroutineScope) context else GlobalScope
47+
return if (context is CoroutineScope) context else CoroutineScope(Dispatchers.Default)
4848
}
4949

5050
internal val Class<*>.declaredNonProxyMethods: List<JavaMethod>

0 commit comments

Comments
 (0)