Skip to content

Commit 413d259

Browse files
committed
Remove deprecations and upgrade to java 11
1 parent f834d58 commit 413d259

19 files changed

+91
-51
lines changed

.github/workflows/pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
java: [ '8', '11', '15' ]
10+
java: [ '11', '15', '17' ]
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v3

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Setup Maven Central
2424
uses: actions/setup-java@v3
2525
with:
26-
java-version: '8'
26+
java-version: '11'
2727
distribution: 'adopt'
2828
server-id: ossrh
2929
server-username: MAVEN_USERNAME

.github/workflows/snapshot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Setup java
1313
uses: actions/setup-java@v3
1414
with:
15-
java-version: '8'
15+
java-version: '11'
1616
distribution: 'adopt'
1717
- name: Build with Maven
1818
run: mvn --batch-mode --update-snapshots verify
@@ -26,7 +26,7 @@ jobs:
2626
- name: Setup Maven Central
2727
uses: actions/setup-java@v3
2828
with:
29-
java-version: '8'
29+
java-version: '11'
3030
distribution: 'adopt'
3131
server-id: ossrh
3232
server-username: MAVEN_USERNAME

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16-
<java.version>1.8</java.version>
16+
<java.version>11</java.version>
1717
<kotlin.version>1.8.21</kotlin.version>
1818
<kotlin-coroutines.version>1.6.4</kotlin-coroutines.version>
1919
<jackson.version>2.14.2</jackson.version>
@@ -279,8 +279,8 @@
279279
<artifactId>maven-compiler-plugin</artifactId>
280280
<version>3.11.0</version>
281281
<configuration>
282-
<source>1.8</source>
283-
<target>1.8</target>
282+
<source>11</source>
283+
<target>11</target>
284284
</configuration>
285285
</plugin>
286286

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ internal open class GenericType(protected val mostSpecificType: JavaType, protec
8383
* Unwrap certain Java types to find the "real" class.
8484
*/
8585
fun unwrapGenericType(javaType: JavaType): JavaType {
86-
val type = replaceTypeVariable(javaType)
87-
return when (type) {
86+
return when (val type = replaceTypeVariable(javaType)) {
8887
is ParameterizedType -> {
8988
val rawType = type.rawType
9089
val genericType = options.genericWrappers.find { it.type == rawType }
@@ -107,7 +106,7 @@ internal open class GenericType(protected val mostSpecificType: JavaType, protec
107106
}
108107
}
109108
is WildcardType -> type.upperBounds.firstOrNull()
110-
?: throw error("Unable to unwrap type, wildcard has no upper bound: $type")
109+
?: error("Unable to unwrap type, wildcard has no upper bound: $type")
111110
is Class<*> -> if (type.isPrimitive) Primitives.wrap(type) else type
112111
else -> error("Unable to unwrap type: $type")
113112
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ internal class SchemaClassScanner(
174174
.coercing(provided.coercing)
175175
.definition(definition)
176176
.build()
177-
}.associateBy { it.name!! }
177+
}.associateBy { it.name }
178178

179179
val unusedDefinitions = (definitionsByName.values - observedDefinitions).toSet()
180180
unusedDefinitions

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import graphql.language.Definition
44
import graphql.language.Document
55
import graphql.parser.MultiSourceReader
66
import graphql.parser.Parser
7+
import graphql.parser.ParserEnvironment
78
import graphql.parser.ParserOptions
89
import graphql.schema.GraphQLScalarType
910
import graphql.schema.idl.RuntimeWiring
@@ -175,11 +176,14 @@ class SchemaParserBuilder {
175176

176177
files.forEach {
177178
val sourceReader = MultiSourceReader.newMultiSourceReader().string(readFile(it), it).trackData(true).build()
178-
documents.add(parser.parseDocument(sourceReader, options))
179+
val environment = ParserEnvironment.newParserEnvironment().document(sourceReader).parserOptions(options).build()
180+
documents.add(parser.parseDocument(environment))
179181
}
180182

181183
if (schemaString.isNotEmpty()) {
182-
documents.add(parser.parseDocument(schemaString.toString(), options))
184+
val sourceReader = MultiSourceReader.newMultiSourceReader().string(schemaString.toString(), null).trackData(true).build()
185+
val environment = ParserEnvironment.newParserEnvironment().document(sourceReader).parserOptions(options).build()
186+
documents.add(parser.parseDocument(environment))
183187
}
184188
} catch (pce: ParseCancellationException) {
185189
val cause = pce.cause
@@ -206,6 +210,6 @@ class SchemaParserBuilder {
206210
}
207211

208212
class InvalidSchemaError(pce: ParseCancellationException, private val recognitionException: RecognitionException) : RuntimeException(pce) {
209-
override val message: String?
213+
override val message: String
210214
get() = "Invalid schema provided (${recognitionException.javaClass.name}) at: ${recognitionException.offendingToken}"
211215
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ internal class TypeClassMatcher(private val definitionsByName: Map<String, TypeD
6868
is ListType -> {
6969
if (realType is ParameterizedType && isListType(realType, potentialMatch)) {
7070
match(potentialMatch, graphQLType.type, realType.actualTypeArguments.first())
71-
} else if ((realType as Class<*>).isArray) {
71+
} else if (realType is Class<*> && realType.isArray) {
7272
match(potentialMatch, graphQLType.type, realType.componentType)
7373
} else {
7474
throw error(potentialMatch, "Java class is not a List or generic type information was lost: $realType")

src/main/kotlin/graphql/kickstart/tools/directive/SchemaDirectiveWiringEnvironmentImpl.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class SchemaDirectiveWiringEnvironmentImpl<T : GraphQLDirectiveContainer?>(
5656
override fun getFieldDataFetcher(): DataFetcher<*> {
5757
checkNotNull(fieldDefinition) { "An output field must be in context to call this method" }
5858
checkNotNull(fieldsContainer) { "An output field container must be in context to call this method" }
59-
return codeRegistry.getDataFetcher(fieldsContainer, fieldDefinition)
59+
val coordinates = FieldCoordinates.coordinates(fieldsContainer, fieldDefinition)
60+
return codeRegistry.getDataFetcher(coordinates, fieldDefinition)
6061
}
6162

6263
override fun setFieldDataFetcher(newDataFetcher: DataFetcher<*>?): GraphQLFieldDefinition {

src/test/kotlin/graphql/kickstart/tools/DirectiveTest.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import graphql.GraphQL
44
import graphql.execution.AsyncExecutionStrategy
55
import graphql.relay.Connection
66
import graphql.relay.SimpleListConnection
7-
import graphql.schema.DataFetcherFactories
8-
import graphql.schema.DataFetchingEnvironment
9-
import graphql.schema.GraphQLFieldDefinition
10-
import graphql.schema.GraphQLObjectType
7+
import graphql.schema.*
118
import graphql.schema.idl.SchemaDirectiveWiring
129
import graphql.schema.idl.SchemaDirectiveWiringEnvironment
1310
import org.junit.Ignore
@@ -325,7 +322,7 @@ class DirectiveTest {
325322

326323
override fun onField(environment: SchemaDirectiveWiringEnvironment<GraphQLFieldDefinition>): GraphQLFieldDefinition {
327324
val field = environment.element
328-
val parentType = environment.fieldsContainer
325+
val parentType = FieldCoordinates.coordinates(environment.fieldsContainer, environment.fieldDefinition)
329326

330327
val originalDataFetcher = environment.codeRegistry.getDataFetcher(parentType, field)
331328
val wrappedDataFetcher = DataFetcherFactories.wrapDataFetcher(originalDataFetcher) { _, value ->
@@ -342,15 +339,15 @@ class DirectiveTest {
342339

343340
override fun onField(environment: SchemaDirectiveWiringEnvironment<GraphQLFieldDefinition>): GraphQLFieldDefinition {
344341
val field = environment.element
345-
val parentType = environment.fieldsContainer
342+
val parentType = FieldCoordinates.coordinates(environment.fieldsContainer, environment.fieldDefinition)
346343

347344
val originalDataFetcher = environment.codeRegistry.getDataFetcher(parentType, field)
348345
val wrappedDataFetcher = DataFetcherFactories.wrapDataFetcher(originalDataFetcher) { _, value ->
349346
val string = value as? String
350347
string + string
351348
}
352349

353-
environment.codeRegistry.dataFetcher(parentType, field, wrappedDataFetcher)
350+
environment.codeRegistry.dataFetcher(parentType, wrappedDataFetcher)
354351

355352
return field
356353
}

0 commit comments

Comments
 (0)