Skip to content

Commit 499798d

Browse files
authored
fix: update graphql-java version to 19.2 (#308)
* fix: update graphql-java version to 19.0 * fix: update graphql-java.version to 19.2 * fix: update spring-boot-dependencies to 2.6.12 * fix: port AstValueHelper implementation from graphql-java * fix: port TypeTraverser from graphq-java * fix: update test port to random * fix: port removed Scalars to JavaScalars * fix: update schema builder * fix: update web controller * fix: add Github CI build * fix: add ntp to mvn * fix: update directiveSupport test * fix: remove defer directive support * fix: remove noOpCoercing hack * fix: update project version to 0.5.0-SNAPSHOT
1 parent 9e8d817 commit 499798d

File tree

33 files changed

+1165
-210
lines changed

33 files changed

+1165
-210
lines changed

.github/workflows/build.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ "master" ]
7+
pull_request:
8+
branches: [ "master" ]
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
java: [ '8', '11' ]
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Set up JDK 11
20+
uses: actions/setup-java@v3
21+
with:
22+
java-version: ${{ matrix.java }}
23+
distribution: 'adopt'
24+
cache: maven
25+
- name: Build with Maven
26+
run: mvn -B -ntp package

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Features
2929
* Merging two or more GraphQL schemas from different JPA entity models
3030
* Support for GraphQL schema auto-configuration, GraphQL Web Rest Controller via Spring Boot Starters
3131
* GraphQL Subscriptions (Experimental)
32-
* GraphQL `@defer` directive (Experimental)
3332

3433
Supported Apis
3534
----------------------

graphql-jpa-query-annotations/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.introproventures</groupId>
88
<artifactId>graphql-jpa-query-dependencies</artifactId>
9-
<version>0.4.20-SNAPSHOT</version>
9+
<version>0.5.0-SNAPSHOT</version>
1010
<relativePath>../graphql-jpa-query-dependencies</relativePath>
1111
</parent>
1212

graphql-jpa-query-autoconfigure/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>com.introproventures</groupId>
55
<artifactId>graphql-jpa-query-build</artifactId>
6-
<version>0.4.20-SNAPSHOT</version>
6+
<version>0.5.0-SNAPSHOT</version>
77
<relativePath>../graphql-jpa-query-build</relativePath>
88
</parent>
99
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
@@ -35,7 +35,7 @@
3535
<dependency>
3636
<groupId>io.github.graphql-java</groupId>
3737
<artifactId>graphql-java-annotations</artifactId>
38-
<version>7.2.1</version>
38+
<version>9.1</version>
3939
<scope>test</scope>
4040
</dependency>
4141
<dependency>

graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaFactoryBean.java

+18-16
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import java.util.stream.Collectors;
1818
import java.util.stream.Stream;
1919

20+
import graphql.schema.GraphQLNamedType;
21+
import graphql.schema.GraphQLSchemaElement;
2022
import org.springframework.beans.factory.config.AbstractFactoryBean;
2123

2224
import graphql.Internal;
@@ -34,9 +36,10 @@
3436
import graphql.schema.GraphQLUnionType;
3537
import graphql.schema.PropertyDataFetcher;
3638
import graphql.schema.TypeResolver;
37-
import graphql.schema.TypeTraverser;
3839
import graphql.util.TraversalControl;
3940
import graphql.util.TraverserContext;
41+
import graphql.util.Traverser;
42+
4043

4144
public class GraphQLSchemaFactoryBean extends AbstractFactoryBean<GraphQLSchema>{
4245

@@ -90,7 +93,7 @@ protected GraphQLSchema createInstance() throws Exception {
9093

9194
List<GraphQLFieldDefinition> queries = Stream.of(managedGraphQLSchemas)
9295
.filter(it -> Optional.ofNullable(it.getQueryType())
93-
.map(GraphQLType::getName)
96+
.map(GraphQLNamedType::getName)
9497
.filter(name -> !"null".equals(name)) // filter out null placeholders
9598
.isPresent())
9699
.peek(schema -> {
@@ -136,8 +139,8 @@ protected GraphQLSchema createInstance() throws Exception {
136139
Set<GraphQLType> types = Stream.of(managedGraphQLSchemas)
137140
.map(GraphQLSchema::getAdditionalTypes)
138141
.flatMap(Collection::stream)
139-
.filter(distinctByKeys(GraphQLType::getName))
140-
.distinct()
142+
.map(GraphQLNamedType.class::cast)
143+
.filter(distinctByKeys(GraphQLNamedType::getName))
141144
.collect(Collectors.toSet());
142145
if (!types.isEmpty()) {
143146
schemaBuilder.additionalTypes(types);
@@ -165,8 +168,7 @@ protected GraphQLSchema createInstance() throws Exception {
165168
.build();
166169
}
167170

168-
@SafeVarargs
169-
private static <T> Predicate<T> distinctByKeys(Function<? super T, ?>... keyExtractors) {
171+
private <T> Predicate<T> distinctByKeys(Function<? super T, ?>... keyExtractors) {
170172
final Map<List<?>, Boolean> seen = new ConcurrentHashMap<>();
171173

172174
return t -> {
@@ -228,7 +230,7 @@ class CodeRegistryVisitor extends GraphQLTypeVisitorStub {
228230
private final GraphQLCodeRegistry.Builder codeRegistry;
229231
private final GraphQLFieldsContainer containerType;
230232
private final String typeName;
231-
233+
232234
CodeRegistryVisitor(GraphQLCodeRegistry.Builder context,
233235
GraphQLCodeRegistry.Builder codeRegistry,
234236
GraphQLFieldsContainer containerType,
@@ -240,40 +242,40 @@ class CodeRegistryVisitor extends GraphQLTypeVisitorStub {
240242
}
241243

242244
@Override
243-
public TraversalControl visitGraphQLFieldDefinition(GraphQLFieldDefinition node, TraverserContext<GraphQLType> context) {
245+
public TraversalControl visitGraphQLFieldDefinition(GraphQLFieldDefinition node, TraverserContext<GraphQLSchemaElement> context) {
244246
GraphQLFieldsContainer parentContainerType = (GraphQLFieldsContainer) context.getParentContext().thisNode();
245-
FieldCoordinates coordinates = parentContainerType.equals(containerType) ? coordinates(typeName, node.getName())
247+
FieldCoordinates coordinates = parentContainerType.equals(containerType) ? coordinates(typeName, node.getName())
246248
: coordinates(parentContainerType, node);
247249

248-
DataFetcher<?> dataFetcher = source.getDataFetcher(parentContainerType,
250+
DataFetcher<?> dataFetcher = source.getDataFetcher(parentContainerType,
249251
node);
250252
if (dataFetcher == null) {
251253
dataFetcher = new PropertyDataFetcher<>(node.getName());
252254
}
253-
254-
codeRegistry.dataFetcherIfAbsent(coordinates,
255+
256+
codeRegistry.dataFetcherIfAbsent(coordinates,
255257
dataFetcher);
256258
return CONTINUE;
257259
}
258260

259261
@Override
260-
public TraversalControl visitGraphQLInterfaceType(GraphQLInterfaceType node, TraverserContext<GraphQLType> context) {
262+
public TraversalControl visitGraphQLInterfaceType(GraphQLInterfaceType node, TraverserContext<GraphQLSchemaElement> context) {
261263
TypeResolver typeResolver = codeRegistry.getTypeResolver(node);
262264

263265
if (typeResolver != null) {
264266
codeRegistry.typeResolverIfAbsent(node, typeResolver);
265267
}
266-
assertTrue(codeRegistry.getTypeResolver(node) != null, "You MUST provide a type resolver for the interface type '" + node.getName() + "'");
268+
assertTrue(codeRegistry.getTypeResolver(node) != null, () -> "You MUST provide a type resolver for the interface type '" + node.getName() + "'");
267269
return CONTINUE;
268270
}
269271

270272
@Override
271-
public TraversalControl visitGraphQLUnionType(GraphQLUnionType node, TraverserContext<GraphQLType> context) {
273+
public TraversalControl visitGraphQLUnionType(GraphQLUnionType node, TraverserContext<GraphQLSchemaElement> context) {
272274
TypeResolver typeResolver = codeRegistry.getTypeResolver(node);
273275
if (typeResolver != null) {
274276
codeRegistry.typeResolverIfAbsent(node, typeResolver);
275277
}
276-
assertTrue(codeRegistry.getTypeResolver(node) != null, "You MUST provide a type resolver for the union type '" + node.getName() + "'");
278+
assertTrue(codeRegistry.getTypeResolver(node) != null, () -> "You MUST provide a type resolver for the union type '" + node.getName() + "'");
277279
return CONTINUE;
278280
}
279281
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.introproventures.graphql.jpa.query.autoconfigure;
2+
3+
import graphql.PublicApi;
4+
import graphql.schema.GraphQLSchemaElement;
5+
import graphql.schema.GraphQLType;
6+
import graphql.schema.GraphQLTypeVisitor;
7+
import graphql.util.TraversalControl;
8+
import graphql.util.Traverser;
9+
import graphql.util.TraverserContext;
10+
import graphql.util.TraverserResult;
11+
import graphql.util.TraverserVisitor;
12+
13+
import java.util.Collection;
14+
import java.util.Collections;
15+
import java.util.List;
16+
import java.util.Map;
17+
import java.util.function.Function;
18+
19+
import static graphql.util.TraversalControl.CONTINUE;
20+
21+
class TypeTraverser {
22+
23+
24+
private final Function<? super GraphQLSchemaElement, ? extends List<GraphQLSchemaElement>> getChildren;
25+
26+
public TypeTraverser(Function<? super GraphQLSchemaElement, ? extends List<GraphQLSchemaElement>> getChildren) {
27+
this.getChildren = getChildren;
28+
}
29+
30+
public TypeTraverser() {
31+
this(GraphQLSchemaElement::getChildren);
32+
}
33+
34+
public TraverserResult depthFirst(GraphQLTypeVisitor graphQLTypeVisitor, GraphQLSchemaElement root) {
35+
return depthFirst(graphQLTypeVisitor, Collections.singletonList(root));
36+
}
37+
38+
public TraverserResult depthFirst(final GraphQLTypeVisitor graphQLTypeVisitor, Collection<? extends GraphQLSchemaElement> roots) {
39+
return depthFirst(initTraverser(), new TraverserDelegateVisitor(graphQLTypeVisitor), roots);
40+
}
41+
42+
public TraverserResult depthFirst(final GraphQLTypeVisitor graphQLTypeVisitor,
43+
Collection<? extends GraphQLSchemaElement> roots,
44+
Map<String, GraphQLSchemaElement> types) {
45+
return depthFirst(initTraverser().rootVar(TypeTraverser.class, types), new TraverserDelegateVisitor(graphQLTypeVisitor), roots);
46+
}
47+
48+
public TraverserResult depthFirst(final Traverser<GraphQLSchemaElement> traverser,
49+
final TraverserDelegateVisitor traverserDelegateVisitor,
50+
Collection<? extends GraphQLSchemaElement> roots) {
51+
return doTraverse(traverser, roots, traverserDelegateVisitor);
52+
}
53+
54+
private Traverser<GraphQLSchemaElement> initTraverser() {
55+
return Traverser.depthFirst(getChildren);
56+
}
57+
58+
private TraverserResult doTraverse(Traverser<GraphQLSchemaElement> traverser, Collection<? extends GraphQLSchemaElement> roots, TraverserDelegateVisitor traverserDelegateVisitor) {
59+
return traverser.traverse(roots, traverserDelegateVisitor);
60+
}
61+
62+
private static class TraverserDelegateVisitor implements TraverserVisitor<GraphQLSchemaElement> {
63+
private final GraphQLTypeVisitor before;
64+
65+
TraverserDelegateVisitor(GraphQLTypeVisitor delegate) {
66+
this.before = delegate;
67+
68+
}
69+
70+
@Override
71+
public TraversalControl enter(TraverserContext<GraphQLSchemaElement> context) {
72+
return context.thisNode().accept(context, before);
73+
}
74+
75+
@Override
76+
public TraversalControl leave(TraverserContext<GraphQLSchemaElement> context) {
77+
return CONTINUE;
78+
}
79+
80+
@Override
81+
public TraversalControl backRef(TraverserContext<GraphQLSchemaElement> context) {
82+
return before.visitBackRef(context);
83+
}
84+
}
85+
86+
}

graphql-jpa-query-autoconfigure/src/test/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfigurationTest.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ public void configure(GraphQLShemaRegistration registry) {
160160
.build();
161161

162162
GraphQLSchema graphQLSchema = GraphQLSchema.newSchema()
163-
.query(GraphQLObjectType.newObject().name("null"))
163+
.query(GraphQLObjectType.newObject().name("null")
164+
.field(GraphQLFieldDefinition.newFieldDefinition()
165+
.name("null")
166+
.type(Scalars.GraphQLString)))
164167
.mutation(mutation)
165168
.codeRegistry(codeRegistry)
166169
.build();
@@ -203,7 +206,7 @@ public void configure(GraphQLShemaRegistration registry) {
203206
GraphQLSchema graphQLSchema = GraphQLSchema.newSchema()
204207
.query(query)
205208
.codeRegistry(codeRegistry)
206-
.additionalDirective(Directives.DeferDirective)
209+
//.additionalDirective(Directives.DeferDirective)
207210
.build();
208211

209212
registry.register(graphQLSchema);
@@ -223,8 +226,7 @@ public void contextLoads() {
223226
public void directivesSupport() {
224227
assertThat(graphQLSchema.getDirectives())
225228
.extracting(GraphQLDirective::getName)
226-
.containsExactly("include", "skip", "defer");
227-
229+
.containsOnly("include", "skip", "specifiedBy", "deprecated");
228230
}
229231

230232
@Test

graphql-jpa-query-boot-starter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.introproventures</groupId>
99
<artifactId>graphql-jpa-query-build</artifactId>
10-
<version>0.4.20-SNAPSHOT</version>
10+
<version>0.5.0-SNAPSHOT</version>
1111
<relativePath>../graphql-jpa-query-build</relativePath>
1212
</parent>
1313

graphql-jpa-query-build/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>com.introproventures</groupId>
55
<artifactId>graphql-jpa-query-dependencies</artifactId>
6-
<version>0.4.20-SNAPSHOT</version>
6+
<version>0.5.0-SNAPSHOT</version>
77
<relativePath>../graphql-jpa-query-dependencies</relativePath>
88
</parent>
99
<artifactId>graphql-jpa-query-build</artifactId>
@@ -35,7 +35,7 @@
3535
<dependency>
3636
<groupId>org.springframework.boot</groupId>
3737
<artifactId>spring-boot-dependencies</artifactId>
38-
<version>2.6.6</version>
38+
<version>2.6.12</version>
3939
<type>pom</type>
4040
<scope>import</scope>
4141
</dependency>

graphql-jpa-query-dependencies/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<parent>
44
<groupId>com.introproventures</groupId>
55
<artifactId>graphql-jpa-query</artifactId>
6-
<version>0.4.20-SNAPSHOT</version>
6+
<version>0.5.0-SNAPSHOT</version>
77
<relativePath>..</relativePath>
88
</parent>
99
<artifactId>graphql-jpa-query-dependencies</artifactId>
1010
<packaging>pom</packaging>
1111

1212
<properties>
13-
<graphql-java.version>13.0</graphql-java.version>
13+
<graphql-java.version>19.2</graphql-java.version>
1414
<hibernate-jpa-2.1-api.version>1.0.0.Final</hibernate-jpa-2.1-api.version>
1515
<evo-inflector.version>1.2.2</evo-inflector.version>
1616
<javax.interceptor-api.version>1.2.2</javax.interceptor-api.version>

graphql-jpa-query-example-merge/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.introproventures</groupId>
99
<artifactId>graphql-jpa-query-build</artifactId>
10-
<version>0.4.20-SNAPSHOT</version>
10+
<version>0.5.0-SNAPSHOT</version>
1111
<relativePath>../graphql-jpa-query-build</relativePath>
1212
</parent>
1313

graphql-jpa-query-example-merge/src/test/java/com/introproventures/graphql/jpa/query/example/ApplicationTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.springframework.test.context.junit4.SpringRunner;
88

99
@RunWith(SpringRunner.class)
10-
@SpringBootTest(webEnvironment=WebEnvironment.DEFINED_PORT)
10+
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)
1111
public class ApplicationTest {
1212

1313
@Test

graphql-jpa-query-example-model-books/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>com.introproventures</groupId>
55
<artifactId>graphql-jpa-query-build</artifactId>
6-
<version>0.4.20-SNAPSHOT</version>
6+
<version>0.5.0-SNAPSHOT</version>
77
<relativePath>../graphql-jpa-query-build</relativePath>
88
</parent>
99
<artifactId>graphql-jpa-query-example-model-books</artifactId>

graphql-jpa-query-example-model-starwars/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>com.introproventures</groupId>
55
<artifactId>graphql-jpa-query-build</artifactId>
6-
<version>0.4.20-SNAPSHOT</version>
6+
<version>0.5.0-SNAPSHOT</version>
77
<relativePath>../graphql-jpa-query-build</relativePath>
88
</parent>
99

graphql-jpa-query-example-relay/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.introproventures</groupId>
88
<artifactId>graphql-jpa-query-build</artifactId>
9-
<version>0.4.20-SNAPSHOT</version>
9+
<version>0.5.0-SNAPSHOT</version>
1010
<relativePath>../graphql-jpa-query-build</relativePath>
1111
</parent>
1212

graphql-jpa-query-example-simple/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.introproventures</groupId>
99
<artifactId>graphql-jpa-query-build</artifactId>
10-
<version>0.4.20-SNAPSHOT</version>
10+
<version>0.5.0-SNAPSHOT</version>
1111
<relativePath>../graphql-jpa-query-build</relativePath>
1212
</parent>
1313

@@ -88,7 +88,7 @@
8888
<goal>push</goal>
8989
</goals>
9090
<configuration>
91-
<pushImage>true</pushImage>
91+
<skipDockerPush>true</skipDockerPush>
9292
</configuration>
9393
</execution>
9494
</executions>

0 commit comments

Comments
 (0)