Skip to content
Merged
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 .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
java-version: '11'
distribution: 'adopt'
server-id: ossrh
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
java-version: '11'
distribution: 'adopt'
server-id: ossrh
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish release
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ kotlin.version=2.1.20

Add the dependency:
```groovy
compile 'com.graphql-java-kickstart:graphql-java-tools:14.0.1'
compile 'io.github.graphql-java-kickstart:graphql-java-tools:14.0.1'
```

### Using Maven
Expand All @@ -41,7 +41,7 @@ Set the Kotlin version in your `<properties>` section:
Add the dependency:
```xml
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<groupId>io.github.graphql-java-kickstart</groupId>
<artifactId>graphql-java-tools</artifactId>
<version>14.0.1</version>
</dependency>
Expand Down
21 changes: 10 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.graphql-java-kickstart</groupId>
<groupId>io.github.graphql-java-kickstart</groupId>
<artifactId>graphql-java-tools</artifactId>
<version>14.0.2-SNAPSHOT</version>
<version>14.0.3-SNAPSHOT</version>
<packaging>jar</packaging>

<name>GraphQL Java Tools</name>
Expand All @@ -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 Expand Up @@ -342,14 +342,13 @@
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.7.0</version>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.9.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -429,8 +428,8 @@
</licenses>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<id>central</id>
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<scm>
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