Skip to content

Commit 0a2e483

Browse files
committed
Do not deprecate custom context option
1 parent cf085df commit 0a2e483

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/main/kotlin/graphql/kickstart/tools/SchemaParserOptions.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,10 @@ data class SchemaParserOptions internal constructor(
6464
private var includeUnusedTypes = false
6565
private var useCommentsForDescriptions = true
6666

67-
@Deprecated("Replaced with graphql.GraphQLContext")
6867
fun contextClass(contextClass: Class<*>) = this.apply {
6968
this.contextClass = contextClass
7069
}
7170

72-
@Deprecated("Replaced with graphql.GraphQLContext")
7371
fun contextClass(contextClass: KClass<*>) = this.apply {
7472
this.contextClass = contextClass.java
7573
}

src/main/kotlin/graphql/kickstart/tools/resolver/MethodFieldResolver.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ internal class MethodFieldResolver(
3333

3434
private val additionalLastArgument =
3535
try {
36-
method.kotlinFunction?.valueParameters?.size ?: method.parameterCount == (field.inputValueDefinitions.size + getIndexOffset() + 1)
36+
(method.kotlinFunction?.valueParameters?.size
37+
?: method.parameterCount) == (field.inputValueDefinitions.size + getIndexOffset() + 1)
3738
} catch (e: InternalError) {
3839
method.parameterCount == (field.inputValueDefinitions.size + getIndexOffset() + 1)
3940
}
@@ -95,7 +96,10 @@ internal class MethodFieldResolver(
9596
if (this.additionalLastArgument) {
9697
when (this.method.parameterTypes.last()) {
9798
null -> throw ResolverError("Expected at least one argument but got none, this is most likely a bug with graphql-java-tools")
98-
options.contextClass -> args.add { environment -> environment.getContext() }
99+
options.contextClass -> args.add { environment ->
100+
environment.graphQlContext[options.contextClass]
101+
?: environment.getContext() // TODO: remove deprecated use in next major release
102+
}
99103
GraphQLContext::class.java -> args.add { environment -> environment.graphQlContext }
100104
else -> args.add { environment -> environment }
101105
}

0 commit comments

Comments
 (0)