Skip to content

Commit 466abcb

Browse files
authored
Merge pull request #245 from graphql-java-kickstart/bugfix/239-support-arrays
Bugfix/239 support arrays
2 parents 08cd0eb + bca99a7 commit 466abcb

File tree

7 files changed

+35
-11
lines changed

7 files changed

+35
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ A few libraries exist to ease the boilerplate pain, including [GraphQL-Java's bu
5454
<dependency>
5555
<groupId>com.graphql-java-kickstart</groupId>
5656
<artifactId>graphql-java-tools</artifactId>
57-
<version>5.4.1</version>
57+
<version>5.5.0</version>
5858
</dependency>
5959
```
6060
```groovy
61-
compile 'com.graphql-java-kickstart:graphql-java-tools:5.4.1'
61+
compile 'com.graphql-java-kickstart:graphql-java-tools:5.5.0'
6262
```
6363

6464
New releases will be available faster in the JCenter repository than in Maven Central. Add the following to use for Maven

example/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2323
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2424
<java.version>1.8</java.version>
25-
<graphql-spring-boot-starter.version>5.2</graphql-spring-boot-starter.version>
26-
<graphql-java-tools.version>5.4.0</graphql-java-tools.version>
25+
<graphql-spring-boot-starter.version>5.5.0</graphql-spring-boot-starter.version>
26+
<graphql-java-tools.version>5.5.0</graphql-java-tools.version>
2727
<kotlin.version>1.3.10</kotlin.version>
2828
</properties>
2929

src/main/kotlin/com/coxautodev/graphql/tools/TypeClassMatcher.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ internal class TypeClassMatcher(private val definitionsByName: Map<String, TypeD
7878
is ListType -> {
7979
if (realType is ParameterizedType && isListType(realType, potentialMatch)) {
8080
match(potentialMatch, graphQLType.type, realType.actualTypeArguments.first())
81+
} else if ((realType as Class<*>).isArray) {
82+
match(potentialMatch, graphQLType.type, realType.componentType)
8183
} else {
8284
throw error(potentialMatch, "Java class is not a List or generic type information was lost: $realType")
8385
}

src/test/groovy/com/coxautodev/graphql/tools/EndToEndSpec.groovy

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,4 +634,20 @@ class EndToEndSpec extends Specification {
634634
subscriber.requestNextElement().data.get("onItemCreatedCoroutineChannelAndSuspendFunction").id == 1
635635
subscriber.expectCompletion()
636636
}
637+
638+
def "generated schema supports arrays"() {
639+
when:
640+
def data = Utils.assertNoGraphQlErrors(gql) {
641+
'''
642+
{
643+
arrayItems {
644+
name
645+
}
646+
}
647+
'''
648+
}
649+
650+
then:
651+
data.arrayItems.collect { it.name } == ['item1', 'item2']
652+
}
637653
}

src/test/java/com/coxautodev/graphql/tools/ReactiveTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
import graphql.execution.AsyncExecutionStrategy;
55
import graphql.schema.GraphQLSchema;
66
import groovy.lang.Closure;
7-
import io.reactivex.Single;
8-
import io.reactivex.internal.operators.single.SingleJust;
7+
//import io.reactivex.Single;
8+
//import io.reactivex.internal.operators.single.SingleJust;
99
import org.junit.Test;
1010

1111
import java.util.HashMap;
1212
import java.util.Optional;
1313
import java.util.concurrent.CompletableFuture;
1414
import java.util.concurrent.Future;
1515

16-
import static io.reactivex.Maybe.just;
16+
//import static io.reactivex.Maybe.just;
1717

1818
public class ReactiveTest {
1919

2020
@Test
2121
public void futureSucceeds() {
2222
SchemaParserOptions options = SchemaParserOptions.newOptions()
23-
.genericWrappers(
24-
new SchemaParserOptions.GenericWrapper(Single.class, 0),
25-
new SchemaParserOptions.GenericWrapper(SingleJust.class, 0)
26-
)
23+
// .genericWrappers(
24+
// new SchemaParserOptions.GenericWrapper(Single.class, 0),
25+
// new SchemaParserOptions.GenericWrapper(SingleJust.class, 0)
26+
// )
2727
.build();
2828
GraphQLSchema schema = SchemaParser.newParser().file("Reactive.graphqls")
2929
.resolvers(new Query())

src/test/kotlin/com/coxautodev/graphql/tools/EndToEndSpec.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ type Query {
7979
dataFetcherResult: Item!
8080
8181
coroutineItems: [Item!]!
82+
83+
arrayItems: [Item!]!
8284
}
8385
8486
type ExtendedType {
@@ -288,6 +290,8 @@ class Query: GraphQLQueryResolver, ListListResolver<String>() {
288290
}
289291

290292
suspend fun coroutineItems(): List<Item> = CompletableDeferred(items).await()
293+
294+
fun arrayItems() = items.toTypedArray()
291295
}
292296

293297
class UnusedRootResolver: GraphQLQueryResolver

travis-build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ saveMavenSettings() {
2424
EOL
2525
}
2626

27+
mvn -B verify
28+
2729
if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${TRAVIS_BRANCH}" = "master" ]; then
2830
saveMavenSettings
2931
git checkout -f ${TRAVIS_BRANCH}

0 commit comments

Comments
 (0)