From f834d58ce1552ac3288c759d59c3ad454663ce17 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Tue, 11 Jul 2023 03:59:44 +0000
Subject: [PATCH 1/4] Update dependency com.graphql-java:graphql-java to v21
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index feedbde4..2bce3a2a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,7 @@
1.8.21
1.6.4
2.14.2
- 20.1
+ 21.0
1.0.4
${java.version}
From 413d25996895105c53bbd52e1a2cac754cfb51b9 Mon Sep 17 00:00:00 2001
From: Oryan M
Date: Tue, 25 Jul 2023 12:19:31 -0400
Subject: [PATCH 2/4] Remove deprecations and upgrade to java 11
---
.github/workflows/pull-request.yml | 2 +-
.github/workflows/release.yml | 2 +-
.github/workflows/snapshot.yml | 4 +-
pom.xml | 6 +--
.../graphql/kickstart/tools/GenericType.kt | 5 +-
.../kickstart/tools/SchemaClassScanner.kt | 2 +-
.../kickstart/tools/SchemaParserBuilder.kt | 10 ++--
.../kickstart/tools/TypeClassMatcher.kt | 2 +-
.../SchemaDirectiveWiringEnvironmentImpl.kt | 3 +-
.../graphql/kickstart/tools/DirectiveTest.kt | 11 ++--
.../kickstart/tools/EndToEndSpecHelper.kt | 51 ++++++++++++-------
.../tools/FieldResolverScannerTest.kt | 2 +
.../MethodFieldResolverDataFetcherTest.kt | 5 +-
.../tools/MethodFieldResolverTest.kt | 11 ++--
.../tools/MissingFieldResolverTest.kt | 2 +
.../graphql/kickstart/tools/ReactiveTest.kt | 2 +
.../kickstart/tools/SchemaClassScannerTest.kt | 18 ++++---
.../kickstart/tools/SchemaParserTest.kt | 2 +
.../kickstart/tools/TypeClassMatcherTest.kt | 2 +
19 files changed, 91 insertions(+), 51 deletions(-)
diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml
index fe542364..bedc63cb 100644
--- a/.github/workflows/pull-request.yml
+++ b/.github/workflows/pull-request.yml
@@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- java: [ '8', '11', '15' ]
+ java: [ '11', '15', '17' ]
steps:
- name: Checkout
uses: actions/checkout@v3
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 74463527..dbb0c381 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -23,7 +23,7 @@ jobs:
- name: Setup Maven Central
uses: actions/setup-java@v3
with:
- java-version: '8'
+ java-version: '11'
distribution: 'adopt'
server-id: ossrh
server-username: MAVEN_USERNAME
diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml
index 6ab13951..710b85cf 100644
--- a/.github/workflows/snapshot.yml
+++ b/.github/workflows/snapshot.yml
@@ -12,7 +12,7 @@ jobs:
- name: Setup java
uses: actions/setup-java@v3
with:
- java-version: '8'
+ java-version: '11'
distribution: 'adopt'
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify
@@ -26,7 +26,7 @@ jobs:
- name: Setup Maven Central
uses: actions/setup-java@v3
with:
- java-version: '8'
+ java-version: '11'
distribution: 'adopt'
server-id: ossrh
server-username: MAVEN_USERNAME
diff --git a/pom.xml b/pom.xml
index 2bce3a2a..6ba520e0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
UTF-8
- 1.8
+ 11
1.8.21
1.6.4
2.14.2
@@ -279,8 +279,8 @@
maven-compiler-plugin
3.11.0
- 1.8
- 1.8
+ 11
+ 11
diff --git a/src/main/kotlin/graphql/kickstart/tools/GenericType.kt b/src/main/kotlin/graphql/kickstart/tools/GenericType.kt
index 35b9df7c..820ab845 100644
--- a/src/main/kotlin/graphql/kickstart/tools/GenericType.kt
+++ b/src/main/kotlin/graphql/kickstart/tools/GenericType.kt
@@ -83,8 +83,7 @@ internal open class GenericType(protected val mostSpecificType: JavaType, protec
* Unwrap certain Java types to find the "real" class.
*/
fun unwrapGenericType(javaType: JavaType): JavaType {
- val type = replaceTypeVariable(javaType)
- return when (type) {
+ return when (val type = replaceTypeVariable(javaType)) {
is ParameterizedType -> {
val rawType = type.rawType
val genericType = options.genericWrappers.find { it.type == rawType }
@@ -107,7 +106,7 @@ internal open class GenericType(protected val mostSpecificType: JavaType, protec
}
}
is WildcardType -> type.upperBounds.firstOrNull()
- ?: throw error("Unable to unwrap type, wildcard has no upper bound: $type")
+ ?: error("Unable to unwrap type, wildcard has no upper bound: $type")
is Class<*> -> if (type.isPrimitive) Primitives.wrap(type) else type
else -> error("Unable to unwrap type: $type")
}
diff --git a/src/main/kotlin/graphql/kickstart/tools/SchemaClassScanner.kt b/src/main/kotlin/graphql/kickstart/tools/SchemaClassScanner.kt
index fd445ff9..650cb679 100644
--- a/src/main/kotlin/graphql/kickstart/tools/SchemaClassScanner.kt
+++ b/src/main/kotlin/graphql/kickstart/tools/SchemaClassScanner.kt
@@ -174,7 +174,7 @@ internal class SchemaClassScanner(
.coercing(provided.coercing)
.definition(definition)
.build()
- }.associateBy { it.name!! }
+ }.associateBy { it.name }
val unusedDefinitions = (definitionsByName.values - observedDefinitions).toSet()
unusedDefinitions
diff --git a/src/main/kotlin/graphql/kickstart/tools/SchemaParserBuilder.kt b/src/main/kotlin/graphql/kickstart/tools/SchemaParserBuilder.kt
index aa9055d7..370ff535 100644
--- a/src/main/kotlin/graphql/kickstart/tools/SchemaParserBuilder.kt
+++ b/src/main/kotlin/graphql/kickstart/tools/SchemaParserBuilder.kt
@@ -4,6 +4,7 @@ import graphql.language.Definition
import graphql.language.Document
import graphql.parser.MultiSourceReader
import graphql.parser.Parser
+import graphql.parser.ParserEnvironment
import graphql.parser.ParserOptions
import graphql.schema.GraphQLScalarType
import graphql.schema.idl.RuntimeWiring
@@ -175,11 +176,14 @@ class SchemaParserBuilder {
files.forEach {
val sourceReader = MultiSourceReader.newMultiSourceReader().string(readFile(it), it).trackData(true).build()
- documents.add(parser.parseDocument(sourceReader, options))
+ val environment = ParserEnvironment.newParserEnvironment().document(sourceReader).parserOptions(options).build()
+ documents.add(parser.parseDocument(environment))
}
if (schemaString.isNotEmpty()) {
- documents.add(parser.parseDocument(schemaString.toString(), options))
+ val sourceReader = MultiSourceReader.newMultiSourceReader().string(schemaString.toString(), null).trackData(true).build()
+ val environment = ParserEnvironment.newParserEnvironment().document(sourceReader).parserOptions(options).build()
+ documents.add(parser.parseDocument(environment))
}
} catch (pce: ParseCancellationException) {
val cause = pce.cause
@@ -206,6 +210,6 @@ class SchemaParserBuilder {
}
class InvalidSchemaError(pce: ParseCancellationException, private val recognitionException: RecognitionException) : RuntimeException(pce) {
- override val message: String?
+ override val message: String
get() = "Invalid schema provided (${recognitionException.javaClass.name}) at: ${recognitionException.offendingToken}"
}
diff --git a/src/main/kotlin/graphql/kickstart/tools/TypeClassMatcher.kt b/src/main/kotlin/graphql/kickstart/tools/TypeClassMatcher.kt
index faa1346d..4ff5e451 100644
--- a/src/main/kotlin/graphql/kickstart/tools/TypeClassMatcher.kt
+++ b/src/main/kotlin/graphql/kickstart/tools/TypeClassMatcher.kt
@@ -68,7 +68,7 @@ internal class TypeClassMatcher(private val definitionsByName: Map {
if (realType is ParameterizedType && isListType(realType, potentialMatch)) {
match(potentialMatch, graphQLType.type, realType.actualTypeArguments.first())
- } else if ((realType as Class<*>).isArray) {
+ } else if (realType is Class<*> && realType.isArray) {
match(potentialMatch, graphQLType.type, realType.componentType)
} else {
throw error(potentialMatch, "Java class is not a List or generic type information was lost: $realType")
diff --git a/src/main/kotlin/graphql/kickstart/tools/directive/SchemaDirectiveWiringEnvironmentImpl.kt b/src/main/kotlin/graphql/kickstart/tools/directive/SchemaDirectiveWiringEnvironmentImpl.kt
index 143fc59d..c11e1881 100644
--- a/src/main/kotlin/graphql/kickstart/tools/directive/SchemaDirectiveWiringEnvironmentImpl.kt
+++ b/src/main/kotlin/graphql/kickstart/tools/directive/SchemaDirectiveWiringEnvironmentImpl.kt
@@ -56,7 +56,8 @@ class SchemaDirectiveWiringEnvironmentImpl(
override fun getFieldDataFetcher(): DataFetcher<*> {
checkNotNull(fieldDefinition) { "An output field must be in context to call this method" }
checkNotNull(fieldsContainer) { "An output field container must be in context to call this method" }
- return codeRegistry.getDataFetcher(fieldsContainer, fieldDefinition)
+ val coordinates = FieldCoordinates.coordinates(fieldsContainer, fieldDefinition)
+ return codeRegistry.getDataFetcher(coordinates, fieldDefinition)
}
override fun setFieldDataFetcher(newDataFetcher: DataFetcher<*>?): GraphQLFieldDefinition {
diff --git a/src/test/kotlin/graphql/kickstart/tools/DirectiveTest.kt b/src/test/kotlin/graphql/kickstart/tools/DirectiveTest.kt
index 03b0dd85..b7d8150f 100644
--- a/src/test/kotlin/graphql/kickstart/tools/DirectiveTest.kt
+++ b/src/test/kotlin/graphql/kickstart/tools/DirectiveTest.kt
@@ -4,10 +4,7 @@ import graphql.GraphQL
import graphql.execution.AsyncExecutionStrategy
import graphql.relay.Connection
import graphql.relay.SimpleListConnection
-import graphql.schema.DataFetcherFactories
-import graphql.schema.DataFetchingEnvironment
-import graphql.schema.GraphQLFieldDefinition
-import graphql.schema.GraphQLObjectType
+import graphql.schema.*
import graphql.schema.idl.SchemaDirectiveWiring
import graphql.schema.idl.SchemaDirectiveWiringEnvironment
import org.junit.Ignore
@@ -325,7 +322,7 @@ class DirectiveTest {
override fun onField(environment: SchemaDirectiveWiringEnvironment): GraphQLFieldDefinition {
val field = environment.element
- val parentType = environment.fieldsContainer
+ val parentType = FieldCoordinates.coordinates(environment.fieldsContainer, environment.fieldDefinition)
val originalDataFetcher = environment.codeRegistry.getDataFetcher(parentType, field)
val wrappedDataFetcher = DataFetcherFactories.wrapDataFetcher(originalDataFetcher) { _, value ->
@@ -342,7 +339,7 @@ class DirectiveTest {
override fun onField(environment: SchemaDirectiveWiringEnvironment): GraphQLFieldDefinition {
val field = environment.element
- val parentType = environment.fieldsContainer
+ val parentType = FieldCoordinates.coordinates(environment.fieldsContainer, environment.fieldDefinition)
val originalDataFetcher = environment.codeRegistry.getDataFetcher(parentType, field)
val wrappedDataFetcher = DataFetcherFactories.wrapDataFetcher(originalDataFetcher) { _, value ->
@@ -350,7 +347,7 @@ class DirectiveTest {
string + string
}
- environment.codeRegistry.dataFetcher(parentType, field, wrappedDataFetcher)
+ environment.codeRegistry.dataFetcher(parentType, wrappedDataFetcher)
return field
}
diff --git a/src/test/kotlin/graphql/kickstart/tools/EndToEndSpecHelper.kt b/src/test/kotlin/graphql/kickstart/tools/EndToEndSpecHelper.kt
index 3b56047c..329f9ed8 100644
--- a/src/test/kotlin/graphql/kickstart/tools/EndToEndSpecHelper.kt
+++ b/src/test/kotlin/graphql/kickstart/tools/EndToEndSpecHelper.kt
@@ -1,8 +1,11 @@
package graphql.kickstart.tools
+import graphql.GraphQLContext
+import graphql.execution.CoercedVariables
import graphql.execution.DataFetcherResult
import graphql.language.ObjectValue
import graphql.language.StringValue
+import graphql.language.Value
import graphql.schema.*
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.channels.Channel
@@ -444,18 +447,22 @@ val customScalarId = GraphQLScalarType.newScalar()
.name("ID")
.description("Overrides built-in ID")
.coercing(object : Coercing {
- override fun serialize(input: Any): String? = when (input) {
+ override fun serialize(input: Any, context: GraphQLContext, locale: Locale) = when (input) {
is String -> input
is UUID -> input.toString()
else -> null
}
- override fun parseValue(input: Any): UUID = parseLiteral(input)
-
- override fun parseLiteral(input: Any): UUID = when (input) {
+ override fun parseValue(input: Any, context: GraphQLContext, locale: Locale) = when (input) {
is StringValue -> UUID.fromString(input.value)
else -> throw CoercingParseLiteralException()
}
+
+ override fun parseLiteral(input: Value<*>, variables: CoercedVariables, context: GraphQLContext, locale: Locale) =
+ when (input) {
+ is StringValue -> UUID.fromString(input.value)
+ else -> throw CoercingParseLiteralException()
+ }
})
.build()
@@ -464,18 +471,22 @@ val customScalarUUID = GraphQLScalarType.newScalar()
.description("UUID")
.coercing(object : Coercing {
- override fun serialize(input: Any): String? = when (input) {
+ override fun serialize(input: Any, context: GraphQLContext, locale: Locale): String? = when (input) {
is String -> input
is UUID -> input.toString()
else -> null
}
- override fun parseValue(input: Any): UUID = parseLiteral(input)
-
- override fun parseLiteral(input: Any): UUID = when (input) {
+ override fun parseValue(input: Any, context: GraphQLContext, locale: Locale): UUID = when (input) {
is StringValue -> UUID.fromString(input.value)
else -> throw CoercingParseLiteralException()
}
+
+ override fun parseLiteral(input: Value<*>, variables: CoercedVariables, context: GraphQLContext, locale: Locale): UUID =
+ when (input) {
+ is StringValue -> UUID.fromString(input.value)
+ else -> throw CoercingParseLiteralException()
+ }
})
.build()
@@ -485,12 +496,19 @@ val customScalarMap = GraphQLScalarType.newScalar()
.coercing(object : Coercing