You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://graphqljavakickstart.slack.com)
5
+
[](https://spectrum.chat/graphql-java-kick)
6
6
7
7
This library allows you to use the GraphQL schema language to build your [graphql-java](https://github.com/graphql-java/graphql-java) schema.
8
8
Inspired by [graphql-tools](https://github.com/apollographql/graphql-tools), it parses the given GraphQL schema and allows you to BYOO (bring your own object) to fill in the implementations.
9
-
GraphQL Java Tools works extremely well if you already have domain POJOs that hold your data (e.g. for RPC, ORM, REST, etc) by allowing you to map these magically to GraphQL objects.
9
+
GraphQL Java Tools works well if you already have domain POJOs that hold your data (e.g. for RPC, ORM, REST, etc) by allowing you to map these "magically" to GraphQL objects.
10
10
11
11
GraphQL Java Tools aims for seamless integration with Java, but works for any JVM language. Try it with Kotlin!
12
12
13
-
## WARNING: NoClassDefFoundError when using Spring Boot
13
+
## We are looking for contributors!
14
+
Are you interested in improving our documentation, working on the codebase, reviewing PRs?
14
15
15
-
If you're using `graphl-java-tools` with Spring Boot version lower than 2.2 you need to set the `kotlin.version` in
16
-
your Spring Boot project explicitly to version 1.3.70, because Spring Boot Starter parent currently overrides it with
17
-
a 1.2.* version of Kotlin.
18
-
`graphql-java-tools` requires 1.3.* however because of its coroutine support. If you don't override this version
19
-
you will run into a `NoClassDefFoundError`.
16
+
[Reach out to us on Spectrum](https://spectrum.chat/graphql-java-kick) and join the team!
20
17
21
-
Spring Boot team has indicated the Kotlin version will be upgraded to 1.3 in Spring Boot 2.2.
18
+
## Quick start
22
19
23
20
### Using Gradle
24
-
Set the Kotlin version in your `gradle.properties`
21
+
Set the Kotlin version in your `gradle.properties`:
Set the Kotlin version in your `<properties>` section
32
+
Set the Kotlin version in your `<properties>` section:
31
33
```xml
32
34
<properties>
33
35
<kotlin.version>1.3.70</kotlin.version>
34
36
</properties>
35
37
```
36
38
39
+
Add the dependency:
40
+
```xml
41
+
<dependency>
42
+
<groupId>com.graphql-java-kickstart</groupId>
43
+
<artifactId>graphql-java-tools</artifactId>
44
+
<version>6.2.0</version>
45
+
</dependency>
46
+
```
47
+
37
48
## Documentation
38
49
39
-
Take a look at our new [documentation](https://www.graphql-java-kickstart.com/tools/) for more details.
50
+
Take a look at our [documentation](https://www.graphql-java-kickstart.com/tools/) for more details.
40
51
41
52
## Why GraphQL Java Tools?
42
53
@@ -49,31 +60,12 @@ A few libraries exist to ease the boilerplate pain, including [GraphQL-Java's bu
49
60
***Class Validation**: Since there aren't any compile-time checks of the type->class relationship, GraphQL Java Tools will warn you if you provide classes/types that you don't need to, as well as erroring if you use the wrong Java class for a certain GraphQL type when it builds the schema.
50
61
***Unit Testing**: Since your GraphQL schema is independent of your data model, this makes your classes simple and extremely testable.
51
62
52
-
## Build with Maven or Gradle
63
+
## WARNING: NoClassDefFoundError when using Spring Boot
Copy file name to clipboardExpand all lines: src/main/kotlin/graphql/kickstart/tools/SchemaClassScanner.kt
+20-3Lines changed: 20 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -77,13 +77,30 @@ internal class SchemaClassScanner(
77
77
do {
78
78
do {
79
79
// Require all implementors of discovered interfaces to be discovered or provided.
80
-
handleInterfaceOrUnionSubTypes(getAllObjectTypesImplementingDiscoveredInterfaces()) { "Object type '${it.name}' implements a known interface, but no class could be found for that type name. Please pass a class for type '${it.name}' in the parser's dictionary." }
80
+
handleDictionaryTypes(getAllObjectTypesImplementingDiscoveredInterfaces()) { "Object type '${it.name}' implements a known interface, but no class could be found for that type name. Please pass a class for type '${it.name}' in the parser's dictionary." }
81
81
} while (scanQueue())
82
82
83
83
// Require all members of discovered unions to be discovered.
84
-
handleInterfaceOrUnionSubTypes(getAllObjectTypeMembersOfDiscoveredUnions()) { "Object type '${it.name}' is a member of a known union, but no class could be found for that type name. Please pass a class for type '${it.name}' in the parser's dictionary." }
84
+
handleDictionaryTypes(getAllObjectTypeMembersOfDiscoveredUnions()) { "Object type '${it.name}' is a member of a known union, but no class could be found for that type name. Please pass a class for type '${it.name}' in the parser's dictionary." }
85
85
} while (scanQueue())
86
86
87
+
// Find unused types and include them if required
88
+
if (options.includeUnusedTypes) {
89
+
do {
90
+
val unusedDefinitions = (definitionsByName.values - (dictionary.keys.toSet() + unvalidatedTypes))
handleDictionaryTypes(listOf(unusedDefinition)) { "Object type '${it.name}' is unused and includeUnusedTypes is true. Please pass a class for type '${it.name}' in the parser's dictionary." }
101
+
} while (scanQueue())
102
+
}
103
+
87
104
return validateAndCreateResult(rootTypeHolder)
88
105
}
89
106
@@ -208,7 +225,7 @@ internal class SchemaClassScanner(
0 commit comments