Skip to content

Commit 213f844

Browse files
committed
Upgrade to v22.x
1 parent 6340ffa commit 213f844

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<dependency>
4646
<groupId>com.graphql-java</groupId>
4747
<artifactId>graphql-java</artifactId>
48-
<version>${graphql-java.version}</version>
48+
<version>22.1</version>
4949
</dependency>
5050
<dependency>
5151
<groupId>org.antlr</groupId>
@@ -306,6 +306,8 @@
306306
<includes>
307307
<include>**/*Test.*</include>
308308
</includes>
309+
<!-- or solve this differently? tests fail-->
310+
<argLine>--add-reads kotlin.stdlib=kotlinx.coroutines.core</argLine>
309311
</configuration>
310312
</plugin>
311313
<plugin>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ internal abstract class FieldResolver(
3535
} else {
3636
{ environment ->
3737
val source = environment.getSource<Any>()
38+
?: throw ResolverError("Expected source object to not be null!")
3839

3940
if (!this.genericType.isAssignableFrom(source.javaClass)) {
4041
throw ResolverError("Expected source object to be an instance of '${this.genericType.getRawClass().name}' but instead got '${source.javaClass.name}'")

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal class MethodFieldResolver(
3030
field: FieldDefinition,
3131
search: FieldResolverScanner.Search,
3232
options: SchemaParserOptions,
33-
val method: Method
33+
val method: Method,
3434
) : FieldResolver(field, search, options, search.type) {
3535

3636
private val log = LoggerFactory.getLogger(javaClass)
@@ -53,6 +53,7 @@ internal class MethodFieldResolver(
5353

5454
args.add { environment ->
5555
val source = environment.getSource<Any>()
56+
?: throw ResolverError("Expected source object to not be null!")
5657
if (!expectedType.isAssignableFrom(source.javaClass)) {
5758
throw ResolverError("Source type (${source.javaClass.name}) is not expected type (${expectedType.name})!")
5859
}
@@ -114,6 +115,7 @@ internal class MethodFieldResolver(
114115
environment.getContext() // TODO: remove deprecated use in next major release
115116
}
116117
}
118+
117119
GraphQLContext::class.java -> args.add { environment -> environment.graphQlContext }
118120
else -> args.add { environment -> environment }
119121
}
@@ -139,19 +141,23 @@ internal class MethodFieldResolver(
139141
return when (type) {
140142
is ListType -> List::class.java.isAssignableFrom(this.genericType.getRawClass(genericParameterType))
141143
&& isConcreteScalarType(environment, type.type, this.genericType.unwrapGenericType(genericParameterType))
144+
142145
is TypeName -> environment.graphQLSchema?.getType(type.name)?.let { isScalar(it) && type.name != "ID" }
143146
?: false
147+
144148
is NonNullType -> isConcreteScalarType(environment, type.type, genericParameterType)
145149
else -> false
146150
}
147151
}
148152

149153
override fun scanForMatches(): List<TypeClassMatcher.PotentialMatch> {
150-
val unwrappedGenericType = genericType.unwrapGenericType(try {
151-
method.kotlinFunction?.returnType?.javaType ?: method.genericReturnType
152-
} catch (e: InternalError) {
153-
method.genericReturnType
154-
})
154+
val unwrappedGenericType = genericType.unwrapGenericType(
155+
try {
156+
method.kotlinFunction?.returnType?.javaType ?: method.genericReturnType
157+
} catch (e: InternalError) {
158+
method.genericReturnType
159+
}
160+
)
155161
val returnValueMatch = TypeClassMatcher.PotentialMatch.returnValue(field.type, unwrappedGenericType, genericType, SchemaClassScanner.ReturnValueReference(method))
156162

157163
return field.inputValueDefinitions.mapIndexed { i, inputDefinition ->
@@ -187,7 +193,7 @@ internal open class MethodFieldResolverDataFetcher(
187193
private val sourceResolver: SourceResolver,
188194
method: Method,
189195
private val args: List<ArgumentPlaceholder>,
190-
private val options: SchemaParserOptions
196+
private val options: SchemaParserOptions,
191197
) : DataFetcher<Any> {
192198

193199
private val resolverMethod = method
@@ -238,11 +244,12 @@ internal open class MethodFieldResolverDataFetcher(
238244
}
239245
}
240246

247+
// TODO use graphql.schema.LightDataFetcher
241248
internal class TrivialMethodFieldResolverDataFetcher(
242249
sourceResolver: SourceResolver,
243250
method: Method,
244251
args: List<ArgumentPlaceholder>,
245-
options: SchemaParserOptions
252+
options: SchemaParserOptions,
246253
) : MethodFieldResolverDataFetcher(sourceResolver, method, args, options),
247254
TrivialDataFetcher<Any> // just to mark it for tracing and optimizations
248255

@@ -256,7 +263,7 @@ private fun invoke(method: Method, instance: Any, args: Array<Any?>): Any? {
256263
try {
257264
return method.invoke(instance, *args)
258265
} catch (e: InvocationTargetException) {
259-
throw e.cause ?: RuntimeException("Unknown error occurred while invoking resolver method")
266+
throw e.cause ?: RuntimeException("Unknown error occurred while invoking resolver method")
260267
}
261268
}
262269

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ input ItemSearchInput {
141141
}
142142
143143
input NewItemInput {
144-
name: String! @deprecated
145-
type: Type! @deprecated(reason: "This is a reason")
144+
name: String @deprecated
145+
type: Type @deprecated(reason: "This is a reason")
146146
}
147147
148148
enum Type {
@@ -536,4 +536,3 @@ val uploadScalar: GraphQLScalarType = GraphQLScalarType.newScalar()
536536
throw CoercingParseLiteralException("Must use variables to specify Upload values")
537537
}
538538
}).build()
539-

0 commit comments

Comments
 (0)