Skip to content

Commit 14afd84

Browse files
committed
Wrap long constructor parameters
1 parent f17ee9b commit 14afd84

22 files changed

+122
-51
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ package graphql.kickstart.tools
33
import kotlin.coroutines.CoroutineContext
44

55
interface CoroutineContextProvider {
6-
fun provide(): CoroutineContext?
6+
7+
fun provide(): CoroutineContext
78
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import graphql.schema.*
55
import graphql.schema.idl.RuntimeWiring
66

77
/**
8-
* Directive behavior is used to wire up directives during schema parsing. Unfortunately, SchemaGeneratorDirectiveHelper
9-
* which contains the logic has package-private access to some members and must be therefore accessed via reflection.
8+
* Directive behavior is used to wire up directives during schema parsing.
109
*/
1110
class DirectiveBehavior {
1211

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import graphql.schema.DataFetchingEnvironment
88
/**
99
* @author Andrew Potter
1010
*/
11-
internal abstract class FieldResolver(val field: FieldDefinition, val search: FieldResolverScanner.Search, val options: SchemaParserOptions, relativeTo: JavaType) {
11+
internal abstract class FieldResolver(
12+
val field: FieldDefinition,
13+
val search: FieldResolverScanner.Search,
14+
val options: SchemaParserOptions,
15+
relativeTo: JavaType
16+
) {
1217
val resolverInfo: ResolverInfo = search.resolverInfo
1318
val genericType = GenericType(search.type, options).relativeToPotentialParent(relativeTo)
1419

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ internal class FieldResolverScanner(val options: SchemaParserOptions) {
111111

112112
private fun verifyMethodArguments(method: java.lang.reflect.Method, requiredCount: Int, search: Search): Boolean {
113113
val appropriateFirstParameter = if (search.requiredFirstParameterType != null) {
114-
if (MethodFieldResolver.Companion.isBatched(method, search)) {
114+
if (MethodFieldResolver.isBatched(method, search)) {
115115
verifyBatchedMethodFirstArgument(method.genericParameterTypes.firstOrNull(), search.requiredFirstParameterType)
116116
} else {
117117
method.genericParameterTypes.firstOrNull()?.let {
@@ -156,7 +156,7 @@ internal class FieldResolverScanner(val options: SchemaParserOptions) {
156156
return false
157157
}
158158

159-
if (!TypeClassMatcher.Companion.isListType(firstType, GenericType(firstType, options))) {
159+
if (!TypeClassMatcher.isListType(firstType, GenericType(firstType, options))) {
160160
return false
161161
}
162162

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ package graphql.kickstart.tools
33
/**
44
* @author Andrew Potter
55
*/
6-
interface GraphQLMutationResolver : GraphQLResolver<Void?>
6+
interface GraphQLMutationResolver : GraphQLResolver<Void>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ package graphql.kickstart.tools
33
/**
44
* @author Andrew Potter
55
*/
6-
interface GraphQLQueryResolver : GraphQLResolver<Void?>
6+
interface GraphQLQueryResolver : GraphQLResolver<Void>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package graphql.kickstart.tools
22

3-
interface GraphQLSubscriptionResolver : GraphQLResolver<Void?>
3+
interface GraphQLSubscriptionResolver : GraphQLResolver<Void>

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

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ import kotlin.reflect.jvm.kotlinFunction
2525
/**
2626
* @author Andrew Potter
2727
*/
28-
internal class MethodFieldResolver(field: FieldDefinition, search: FieldResolverScanner.Search, options: SchemaParserOptions, val method: Method) : FieldResolver(field, search, options, search.type) {
28+
internal class MethodFieldResolver(
29+
field: FieldDefinition,
30+
search: FieldResolverScanner.Search,
31+
options: SchemaParserOptions,
32+
val method: Method
33+
) : FieldResolver(field, search, options, search.type) {
2934

3035
companion object {
3136
fun isBatched(method: Method, search: FieldResolverScanner.Search): Boolean {
@@ -179,7 +184,12 @@ internal class MethodFieldResolver(field: FieldDefinition, search: FieldResolver
179184
override fun toString() = "MethodFieldResolver{method=$method}"
180185
}
181186

182-
open class MethodFieldResolverDataFetcher(private val sourceResolver: SourceResolver, method: Method, private val args: List<ArgumentPlaceholder>, private val options: SchemaParserOptions) : DataFetcher<Any> {
187+
open class MethodFieldResolverDataFetcher(
188+
private val sourceResolver: SourceResolver,
189+
method: Method,
190+
private val args: List<ArgumentPlaceholder>,
191+
private val options: SchemaParserOptions
192+
) : DataFetcher<Any> {
183193

184194
private val resolverMethod = method
185195
private val isSuspendFunction = try {
@@ -220,18 +230,21 @@ open class MethodFieldResolverDataFetcher(private val sourceResolver: SourceReso
220230
}
221231

222232
/**
223-
* Function that return the object used to fetch the data
224-
* It can be a DataFetcher or an entity
233+
* Function that returns the object used to fetch the data.
234+
* It can be a DataFetcher or an entity.
225235
*/
226236
@Suppress("unused")
227237
open fun getWrappedFetchingObject(environment: DataFetchingEnvironment): Any {
228238
return sourceResolver(environment)
229239
}
230240
}
231241

232-
open class TrivialMethodFieldResolverDataFetcher(sourceResolver: SourceResolver, method: Method, args: List<ArgumentPlaceholder>, options: SchemaParserOptions) : MethodFieldResolverDataFetcher(sourceResolver, method, args, options), TrivialDataFetcher<Any> {
233-
234-
}
242+
open class TrivialMethodFieldResolverDataFetcher(
243+
sourceResolver: SourceResolver,
244+
method: Method,
245+
args: List<ArgumentPlaceholder>,
246+
options: SchemaParserOptions
247+
) : MethodFieldResolverDataFetcher(sourceResolver, method, args, options), TrivialDataFetcher<Any>
235248

236249
private suspend inline fun invokeSuspend(target: Any, resolverMethod: Method, args: Array<Any?>): Any? {
237250
return suspendCoroutineUninterceptedOrReturn { continuation ->
@@ -256,7 +269,12 @@ private inline fun invoke(method: Method, instance: Any, args: Array<Any?>): Any
256269
}
257270
}
258271

259-
class BatchedMethodFieldResolverDataFetcher(sourceResolver: SourceResolver, method: Method, args: List<ArgumentPlaceholder>, options: SchemaParserOptions) : MethodFieldResolverDataFetcher(sourceResolver, method, args, options) {
272+
class BatchedMethodFieldResolverDataFetcher(
273+
sourceResolver: SourceResolver,
274+
method: Method,
275+
args: List<ArgumentPlaceholder>,
276+
options: SchemaParserOptions
277+
) : MethodFieldResolverDataFetcher(sourceResolver, method, args, options) {
260278
@Batched
261279
override fun get(environment: DataFetchingEnvironment) = super.get(environment)
262280
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package graphql.kickstart.tools;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
5+
/**
6+
* @author Andrew Potter
7+
*/
8+
public interface ObjectMapperConfigurer {
9+
10+
void configure(ObjectMapper mapper, ObjectMapperConfigurerContext context);
11+
}

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

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)