Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<kotlin.version>2.3.10</kotlin.version>
<kotlin-coroutines.version>1.10.2</kotlin-coroutines.version>
<jackson.version>2.21.0</jackson.version>
<graphql-java.version>23.1</graphql-java.version>
<graphql-java.version>25.0</graphql-java.version>
<reactive-streams.version>1.0.4</reactive-streams.version>

<maven.compiler.source>${java.version}</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class RelayConnectionFactory : TypeDefinitionFactory {
.fieldDefinition(FieldDefinition("pageInfo", TypeName("PageInfo")))
.build()

private fun createEdgeDefinition(connectionType: String, nodeType: String): ObjectTypeDefinition =
private fun createEdgeDefinition(connectionType: String, nodeType: String?): ObjectTypeDefinition =
ObjectTypeDefinition.newObjectTypeDefinition()
.name(connectionType + "Edge")
.fieldDefinition(FieldDefinition("cursor", TypeName("String")))
Expand All @@ -70,7 +70,7 @@ class RelayConnectionFactory : TypeDefinitionFactory {
.fieldDefinition(FieldDefinition("endCursor", TypeName("String")))
.build()

private fun Directive.forTypeName(): String {
private fun Directive.forTypeName(): String? {
return (this.getArgument("for").value as StringValue).value
}

Expand All @@ -82,7 +82,13 @@ class RelayConnectionFactory : TypeDefinitionFactory {
return this.directives.map { it.withField(this) }
}

class DirectiveWithField(val field: FieldDefinition, name: String, arguments: List<Argument>, sourceLocation: SourceLocation, comments: List<Comment>) : Directive(name, arguments, sourceLocation, comments, IgnoredChars.EMPTY, emptyMap()) {
class DirectiveWithField(
val field: FieldDefinition,
name: String,
arguments: List<Argument>,
sourceLocation: SourceLocation?,
comments: List<Comment>
) : Directive(name, arguments, sourceLocation, comments, IgnoredChars.EMPTY, emptyMap()) {
fun getTypeName(): String {
val type = field.type
if (type is NonNullType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,9 @@ internal class FieldResolverScanner(val options: SchemaParserOptions) {
isSubscription = isSubscription || search.source is GraphQLSubscriptionResolver
}

val sourceName = if (field.sourceLocation != null && field.sourceLocation.sourceName != null) field.sourceLocation.sourceName else "<unknown>"
val sourceLocation = if (field.sourceLocation != null) "$sourceName:${field.sourceLocation.line}" else "<unknown>"
val sourceName = field.sourceLocation?.sourceName ?: "<unknown>"
val sourceLocation = field.sourceLocation?.let { "$sourceName:${it.line}" } ?: "<unknown>"

return "No method${if (scannedProperties) " or field" else ""} found as defined in schema $sourceLocation with any of the following signatures " +
"(with or without one of $allowedLastArgumentTypes as the last argument), in priority order:\n${signatures.joinToString("\n ")}" +
if (isSubscription) "\n\nNote that a Subscription data fetcher must return a Publisher of events" else ""
Expand Down
8 changes: 5 additions & 3 deletions src/test/kotlin/graphql/kickstart/tools/EndToEndSpecHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ val customScalarUUID = GraphQLScalarType.newScalar()
val customScalarMap = GraphQLScalarType.newScalar()
.name("customScalarMap")
.description("customScalarMap")
.coercing(object : Coercing<Map<String, Any>, Map<String, Any>> {
.coercing(object : Coercing<Map<String, Any?>, Map<String, Any?>> {

@Suppress("UNCHECKED_CAST")
override fun parseValue(input: Any, context: GraphQLContext, locale: Locale): Map<String, Any> = input as Map<String, Any>
Expand All @@ -515,8 +515,10 @@ val customScalarMap = GraphQLScalarType.newScalar()
variables: CoercedVariables,
context: GraphQLContext,
locale: Locale
): Map<String, Any> =
(input as ObjectValue).objectFields.associateBy { it.name }.mapValues { (it.value.value as StringValue).value }
): Map<String, Any?> =
(input as ObjectValue).objectFields
.associateBy { it.name }
.mapValues { (it.value.value as StringValue).value }
})
.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,22 +296,25 @@ class MethodFieldResolverDataFetcherTest {
return FieldResolverScanner(options).findFieldResolver(field, resolverInfo).createDataFetcher()
}

private fun createEnvironment(source: Any = Object(), arguments: Map<String, Any> = emptyMap(), context: GraphQLContext? = null): DataFetchingEnvironment {
return DataFetchingEnvironmentImpl.newDataFetchingEnvironment(buildExecutionContext())
.source(source)
.arguments(arguments)
.graphQLContext(context)
.build()
}

private fun buildExecutionContext(): ExecutionContext {
private fun createEnvironment(
source: Any = Object(),
arguments: Map<String, Any> = emptyMap(),
context: GraphQLContext = GraphQLContext.newContext().build()
) = DataFetchingEnvironmentImpl.newDataFetchingEnvironment(buildExecutionContext(context))
.source(source)
.arguments(arguments)
.graphQLContext(context)
.build()

private fun buildExecutionContext(context: GraphQLContext): ExecutionContext {
val executionStrategy = object : ExecutionStrategy() {
override fun execute(executionContext: ExecutionContext, parameters: ExecutionStrategyParameters): CompletableFuture<ExecutionResult> {
throw AssertionError("should not be called")
}
}
val executionId = ExecutionId.from("executionId123")
return ExecutionContextBuilder.newExecutionContextBuilder()
.graphQLContext(context)
.instrumentation(SimplePerformantInstrumentation.INSTANCE)
.executionId(executionId)
.queryStrategy(executionStrategy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class MethodFieldResolverTest {
val value get() = internalValue

companion object {
fun of(input: Any) = when (input) {
fun of(input: Any?) = when (input) {
is String -> CustomScalar(input)
else -> throw IllegalArgumentException()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SchemaClassScannerDirectiveTest {
assertEquals(value.value, "some thing")
}

data class CustomValue(val value: String)
data class CustomValue(val value: String?)
private val customValueScalar: GraphQLScalarType = GraphQLScalarType.newScalar()
.name("CustomValue")
.coercing(object : Coercing<CustomValue, String> {
Expand Down
12 changes: 6 additions & 6 deletions src/test/kotlin/graphql/kickstart/tools/SchemaParserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ class SchemaParserTest {
.getFieldDefinition("id")
.definition!!.sourceLocation
assertNotNull(sourceLocation)
assertEquals(sourceLocation.line, 2)
assertEquals(sourceLocation.column, 5)
assertNull(sourceLocation.sourceName)
assertEquals(sourceLocation?.line, 2)
assertEquals(sourceLocation?.column, 5)
assertNull(sourceLocation?.sourceName)
}

@Test
Expand All @@ -280,9 +280,9 @@ class SchemaParserTest {
.getFieldDefinition("id")
.definition!!.sourceLocation
assertNotNull(sourceLocation)
assertEquals(sourceLocation.line, 2)
assertEquals(sourceLocation.column, 3)
assertEquals(sourceLocation.sourceName, "Test.graphqls")
assertEquals(sourceLocation?.line, 2)
assertEquals(sourceLocation?.column, 3)
assertEquals(sourceLocation?.sourceName, "Test.graphqls")
}

@Test
Expand Down