Skip to content

Commit 1bfd3f9

Browse files
author
Oryan M
committed
Merge branch 'master' into #434_GraphQlInputObjectType_at_runtime_wiring_on_nonnull_input
# Conflicts: # src/test/groovy/graphql/kickstart/tools/SchemaParserSpec.groovy
2 parents 6ff271f + faf59af commit 1bfd3f9

File tree

56 files changed

+3299
-3374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3299
-3374
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: Question
4-
url: https://spectrum.chat/graphql-java-kick
5-
about: Anything you are not sure about? Ask the community on Spectrum!
4+
url: https://github.com/graphql-java-kickstart/graphql-java-tools/discussions
5+
about: Anything you are not sure about? Ask the community!

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![TravisCI Build](https://travis-ci.org/graphql-java-kickstart/graphql-java-tools.svg?branch=master)](https://travis-ci.org/graphql-java-kickstart/graphql-java-tools)
44
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.graphql-java-kickstart/graphql-java-tools/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.graphql-java-kickstart/graphql-java-tools)
5-
[![Chat on Spectrum](https://img.shields.io/badge/spectrum-join%20the%20community-%23800080)](https://spectrum.chat/graphql-java-kick)
5+
[![Discuss on GitHub](https://img.shields.io/badge/GitHub-discuss-orange)](https://github.com/graphql-java-kickstart/graphql-java-tools/discussions)
66

77
This library allows you to use the GraphQL schema language to build your [graphql-java](https://github.com/graphql-java/graphql-java) schema.
88
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.
@@ -11,9 +11,10 @@ GraphQL Java Tools works well if you already have domain POJOs that hold your da
1111
GraphQL Java Tools aims for seamless integration with Java, but works for any JVM language. Try it with Kotlin!
1212

1313
## We are looking for contributors!
14+
1415
Are you interested in improving our documentation, working on the codebase, reviewing PRs?
1516

16-
[Reach out to us on Spectrum](https://spectrum.chat/graphql-java-kick) and join the team!
17+
[Reach out to us on GitHub](https://github.com/graphql-java-kickstart/graphql-java-tools/discussions) and join the team!
1718

1819
## Quick start
1920

@@ -25,7 +26,7 @@ kotlin.version=1.3.70
2526

2627
Add the dependency:
2728
```groovy
28-
compile 'com.graphql-java-kickstart:graphql-java-tools:6.3.0'
29+
compile 'com.graphql-java-kickstart:graphql-java-tools:11.0.0'
2930
```
3031

3132
### Using Maven
@@ -41,7 +42,7 @@ Add the dependency:
4142
<dependency>
4243
<groupId>com.graphql-java-kickstart</groupId>
4344
<artifactId>graphql-java-tools</artifactId>
44-
<version>6.3.0</version>
45+
<version>11.0.0</version>
4546
</dependency>
4647
```
4748

pom.xml

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.graphql-java-kickstart</groupId>
66
<artifactId>graphql-java-tools</artifactId>
7-
<version>6.3.1-SNAPSHOT</version>
7+
<version>11.0.1-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

1010
<name>GraphQL Java Tools</name>
@@ -14,17 +14,28 @@
1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616
<java.version>1.8</java.version>
17-
<kotlin.version>1.3.72</kotlin.version>
18-
<kotlin-coroutines.version>1.3.9</kotlin-coroutines.version>
17+
<kotlin.version>1.4.21</kotlin.version>
18+
<kotlin-coroutines.version>1.4.2</kotlin-coroutines.version>
1919
<jackson.version>2.10.3</jackson.version>
20-
<graphql-java.version>15.0</graphql-java.version>
20+
<graphql-java.version>16.2</graphql-java.version>
2121

2222
<maven.compiler.source>${java.version}</maven.compiler.source>
2323
<maven.compiler.target>${java.version}</maven.compiler.target>
2424
<useReleaseProfile>false</useReleaseProfile>
2525
<project.scm.id>github</project.scm.id>
2626
</properties>
2727

28+
<dependencyManagement>
29+
<dependencies>
30+
<!-- graphql-java defines this dependency as 'runtime', but we need it at compile time -->
31+
<dependency>
32+
<groupId>org.antlr</groupId>
33+
<artifactId>antlr4-runtime</artifactId>
34+
<scope>compile</scope>
35+
</dependency>
36+
</dependencies>
37+
</dependencyManagement>
38+
2839
<dependencies>
2940
<dependency>
3041
<groupId>org.jetbrains.kotlin</groupId>
@@ -112,7 +123,7 @@
112123
<dependency>
113124
<groupId>org.slf4j</groupId>
114125
<artifactId>slf4j-api</artifactId>
115-
<version>1.7.25</version>
126+
<version>1.7.30</version>
116127
</dependency>
117128

118129
<!-- Optional for supporting spring proxies -->
@@ -144,9 +155,9 @@
144155
</exclusions>
145156
</dependency>
146157
<dependency>
147-
<groupId>org.spockframework</groupId>
148-
<artifactId>spock-core</artifactId>
149-
<version>1.0-groovy-2.4</version>
158+
<groupId>junit</groupId>
159+
<artifactId>junit</artifactId>
160+
<version>4.13.1</version>
150161
<scope>test</scope>
151162
</dependency>
152163
<dependency>
@@ -198,7 +209,6 @@
198209
<configuration>
199210
<sources>
200211
<source>src/test/kotlin</source>
201-
<source>src/test/groovy</source>
202212
</sources>
203213
</configuration>
204214
</execution>
@@ -229,23 +239,6 @@
229239
</plugin>
230240

231241

232-
<!-- Compile Groovy tests -->
233-
<plugin>
234-
<groupId>org.codehaus.gmavenplus</groupId>
235-
<artifactId>gmavenplus-plugin</artifactId>
236-
<version>1.5</version>
237-
<executions>
238-
<execution>
239-
<goals>
240-
<goal>generateStubs</goal>
241-
<goal>testGenerateStubs</goal>
242-
<goal>addTestSources</goal>
243-
<goal>testCompile</goal>
244-
</goals>
245-
</execution>
246-
</executions>
247-
</plugin>
248-
249242
<plugin>
250243
<groupId>org.apache.maven.plugins</groupId>
251244
<artifactId>maven-compiler-plugin</artifactId>
@@ -268,7 +261,6 @@
268261
</dependencies>
269262
<configuration>
270263
<includes>
271-
<include>**/*Spec.*</include>
272264
<include>**/*Test.*</include>
273265
</includes>
274266
</configuration>

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

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -333,26 +333,29 @@ internal class SchemaClassScanner(
333333
}
334334

335335
is InputObjectTypeDefinition -> {
336-
graphQLType.inputValueDefinitions.forEach { inputValueDefinition ->
337-
val inputGraphQLType = inputValueDefinition.type.unwrap()
338-
if (inputGraphQLType is TypeName && !ScalarInfo.GRAPHQL_SPECIFICATION_SCALARS_DEFINITIONS.containsKey(inputGraphQLType.name)) {
339-
val inputValueJavaType = findInputValueType(inputValueDefinition.name, inputGraphQLType, javaType.unwrap())
340-
if (inputValueJavaType != null) {
341-
handleFoundType(typeClassMatcher.match(TypeClassMatcher.PotentialMatch.parameterType(
342-
inputValueDefinition.type,
343-
inputValueJavaType,
344-
GenericType(javaType, options).relativeToType(inputValueJavaType),
345-
InputObjectReference(inputValueDefinition)
346-
)))
347-
} else {
348-
var mappingAdvice = "Try adding it manually to the dictionary"
349-
if (javaType.unwrap().name.contains("Map")) {
350-
mappingAdvice = " or add a class to represent your input type instead of a Map."
336+
val inputObjectTypes = listOf(graphQLType) + inputExtensionDefinitions.filter { it.name == graphQLType.name }
337+
inputObjectTypes
338+
.flatMap { it.inputValueDefinitions }
339+
.forEach { inputValueDefinition ->
340+
val inputGraphQLType = inputValueDefinition.type.unwrap()
341+
if (inputGraphQLType is TypeName && !ScalarInfo.GRAPHQL_SPECIFICATION_SCALARS_DEFINITIONS.containsKey(inputGraphQLType.name)) {
342+
val inputValueJavaType = findInputValueType(inputValueDefinition.name, inputGraphQLType, javaType.unwrap())
343+
if (inputValueJavaType != null) {
344+
handleFoundType(typeClassMatcher.match(TypeClassMatcher.PotentialMatch.parameterType(
345+
inputValueDefinition.type,
346+
inputValueJavaType,
347+
GenericType(javaType, options).relativeToType(inputValueJavaType),
348+
InputObjectReference(inputValueDefinition)
349+
)))
350+
} else {
351+
var mappingAdvice = "Try adding it manually to the dictionary"
352+
if (javaType.unwrap().name.contains("Map")) {
353+
mappingAdvice = " or add a class to represent your input type instead of a Map."
354+
}
355+
log.warn("Cannot find definition for field '${inputValueDefinition.name}: ${inputGraphQLType.name}' on input type '${graphQLType.name}' -> ${javaType.unwrap().name}. $mappingAdvice")
351356
}
352-
log.warn("Cannot find definition for field '${inputValueDefinition.name}: ${inputGraphQLType.name}' on input type '${graphQLType.name}' -> ${javaType.unwrap().name}. $mappingAdvice")
353357
}
354358
}
355-
}
356359
}
357360
}
358361
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import graphql.language.*
1010
import graphql.schema.*
1111
import graphql.schema.idl.RuntimeWiring
1212
import graphql.schema.idl.ScalarInfo
13-
import graphql.schema.idl.SchemaGeneratorHelper
13+
import graphql.schema.idl.SchemaGeneratorHelperExt
1414
import graphql.schema.visibility.NoIntrospectionGraphqlFieldVisibility
1515
import org.slf4j.LoggerFactory
1616
import kotlin.reflect.KClass
@@ -58,7 +58,7 @@ class SchemaParser internal constructor(
5858

5959
private val codeRegistryBuilder = GraphQLCodeRegistry.newCodeRegistry()
6060

61-
private val schemaGeneratorHelper = SchemaGeneratorHelper()
61+
private val schemaGeneratorHelper = SchemaGeneratorHelperExt()
6262
private val schemaGeneratorDirectiveHelper = SchemaGeneratorDirectiveHelper()
6363
private val schemaDirectiveParameters = SchemaGeneratorDirectiveHelper.Parameters(null, runtimeWiring, null, codeRegistryBuilder)
6464

@@ -314,7 +314,7 @@ class SchemaParser internal constructor(
314314
.build()
315315

316316

317-
output.add(schemaGeneratorHelper.buildDirective(directive, setOf(graphQLDirective), directiveLocation, runtimeWiring.comparatorRegistry))
317+
output.add(schemaGeneratorHelper.buildDirective(directive, graphQLDirective, directiveLocation, runtimeWiring.comparatorRegistry))
318318
}
319319
}
320320

@@ -363,8 +363,8 @@ class SchemaParser internal constructor(
363363
private fun buildDefaultValue(value: Value<*>?): Any? {
364364
return when (value) {
365365
null -> null
366-
is IntValue -> value.value
367-
is FloatValue -> value.value
366+
is IntValue -> value.value.toInt()
367+
is FloatValue -> value.value.toDouble()
368368
is StringValue -> value.value
369369
is EnumValue -> value.name
370370
is BooleanValue -> value.isValue

src/main/kotlin/graphql/kickstart/tools/directive/SchemaDirectiveWiringEnvironmentImpl.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
import graphql.Internal;
44
import graphql.language.NamedNode;
55
import graphql.language.NodeParentTree;
6-
import graphql.schema.*;
6+
import graphql.schema.DataFetcher;
7+
import graphql.schema.FieldCoordinates;
8+
import graphql.schema.GraphQLCodeRegistry;
9+
import graphql.schema.GraphQLDirective;
10+
import graphql.schema.GraphQLDirectiveContainer;
11+
import graphql.schema.GraphQLFieldDefinition;
12+
import graphql.schema.GraphQLFieldsContainer;
13+
import graphql.schema.GraphqlElementParentTree;
714
import graphql.schema.idl.SchemaDirectiveWiringEnvironment;
815
import graphql.schema.idl.TypeDefinitionRegistry;
916
import graphql.util.FpKit;
@@ -17,14 +24,14 @@
1724
/*
1825
* DO NOT EDIT THIS FILE!
1926
*
20-
* File copied from com.graphql-java.graphql-java:15.0 without any changes.
27+
* File copied from com.graphql-java.graphql-java:16.1 without any changes.
2128
*/
2229
@Internal
2330
public class SchemaDirectiveWiringEnvironmentImpl<T extends GraphQLDirectiveContainer> implements SchemaDirectiveWiringEnvironment<T> {
2431

2532
private final T element;
2633
private final Map<String, GraphQLDirective> directives;
27-
private final NodeParentTree<NamedNode> nodeParentTree;
34+
private final NodeParentTree<NamedNode<?>> nodeParentTree;
2835
private final TypeDefinitionRegistry typeDefinitionRegistry;
2936
private final Map<String, Object> context;
3037
private final GraphQLCodeRegistry.Builder codeRegistry;
@@ -33,12 +40,7 @@ public class SchemaDirectiveWiringEnvironmentImpl<T extends GraphQLDirectiveCont
3340
private final GraphQLFieldDefinition fieldDefinition;
3441
private final GraphQLDirective registeredDirective;
3542

36-
public SchemaDirectiveWiringEnvironmentImpl(
37-
T element,
38-
List<GraphQLDirective> directives,
39-
GraphQLDirective registeredDirective,
40-
SchemaGeneratorDirectiveHelper.Parameters parameters
41-
) {
43+
public SchemaDirectiveWiringEnvironmentImpl(T element, List<GraphQLDirective> directives, GraphQLDirective registeredDirective, SchemaGeneratorDirectiveHelper.Parameters parameters) {
4244
this.element = element;
4345
this.registeredDirective = registeredDirective;
4446
this.typeDefinitionRegistry = parameters.getTypeRegistry();
@@ -77,7 +79,7 @@ public boolean containsDirective(String directiveName) {
7779
}
7880

7981
@Override
80-
public NodeParentTree<NamedNode> getNodeParentTree() {
82+
public NodeParentTree<NamedNode<?>> getNodeParentTree() {
8183
return nodeParentTree;
8284
}
8385

@@ -112,14 +114,14 @@ public GraphQLFieldDefinition getFieldDefinition() {
112114
}
113115

114116
@Override
115-
public DataFetcher getFieldDataFetcher() {
117+
public DataFetcher<?> getFieldDataFetcher() {
116118
assertNotNull(fieldDefinition, () -> "An output field must be in context to call this method");
117119
assertNotNull(fieldsContainer, () -> "An output field container must be in context to call this method");
118120
return codeRegistry.getDataFetcher(fieldsContainer, fieldDefinition);
119121
}
120122

121123
@Override
122-
public GraphQLFieldDefinition setFieldDataFetcher(DataFetcher newDataFetcher) {
124+
public GraphQLFieldDefinition setFieldDataFetcher(DataFetcher<?> newDataFetcher) {
123125
assertNotNull(fieldDefinition, () -> "An output field must be in context to call this method");
124126
assertNotNull(fieldsContainer, () -> "An output field container must be in context to call this method");
125127

0 commit comments

Comments
 (0)