Skip to content

fix: update graphql-java version to 19.2 #308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Oct 22, 2022
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
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI

on:
workflow_dispatch:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8', '11' ]
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
cache: maven
- name: Build with Maven
run: mvn -B -ntp package
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Features
* Merging two or more GraphQL schemas from different JPA entity models
* Support for GraphQL schema auto-configuration, GraphQL Web Rest Controller via Spring Boot Starters
* GraphQL Subscriptions (Experimental)
* GraphQL `@defer` directive (Experimental)

Supported Apis
----------------------
Expand Down
2 changes: 1 addition & 1 deletion graphql-jpa-query-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-dependencies</artifactId>
<version>0.4.20-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-dependencies</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions graphql-jpa-query-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.4.20-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
Expand Down Expand Up @@ -35,7 +35,7 @@
<dependency>
<groupId>io.github.graphql-java</groupId>
<artifactId>graphql-java-annotations</artifactId>
<version>7.2.1</version>
<version>9.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import graphql.schema.GraphQLNamedType;
import graphql.schema.GraphQLSchemaElement;
import org.springframework.beans.factory.config.AbstractFactoryBean;

import graphql.Internal;
Expand All @@ -34,9 +36,10 @@
import graphql.schema.GraphQLUnionType;
import graphql.schema.PropertyDataFetcher;
import graphql.schema.TypeResolver;
import graphql.schema.TypeTraverser;
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;
import graphql.util.Traverser;


public class GraphQLSchemaFactoryBean extends AbstractFactoryBean<GraphQLSchema>{

Expand Down Expand Up @@ -90,7 +93,7 @@ protected GraphQLSchema createInstance() throws Exception {

List<GraphQLFieldDefinition> queries = Stream.of(managedGraphQLSchemas)
.filter(it -> Optional.ofNullable(it.getQueryType())
.map(GraphQLType::getName)
.map(GraphQLNamedType::getName)
.filter(name -> !"null".equals(name)) // filter out null placeholders
.isPresent())
.peek(schema -> {
Expand Down Expand Up @@ -136,8 +139,8 @@ protected GraphQLSchema createInstance() throws Exception {
Set<GraphQLType> types = Stream.of(managedGraphQLSchemas)
.map(GraphQLSchema::getAdditionalTypes)
.flatMap(Collection::stream)
.filter(distinctByKeys(GraphQLType::getName))
.distinct()
.map(GraphQLNamedType.class::cast)
.filter(distinctByKeys(GraphQLNamedType::getName))
.collect(Collectors.toSet());
if (!types.isEmpty()) {
schemaBuilder.additionalTypes(types);
Expand Down Expand Up @@ -165,8 +168,7 @@ protected GraphQLSchema createInstance() throws Exception {
.build();
}

@SafeVarargs
private static <T> Predicate<T> distinctByKeys(Function<? super T, ?>... keyExtractors) {
private <T> Predicate<T> distinctByKeys(Function<? super T, ?>... keyExtractors) {
final Map<List<?>, Boolean> seen = new ConcurrentHashMap<>();

return t -> {
Expand Down Expand Up @@ -228,7 +230,7 @@ class CodeRegistryVisitor extends GraphQLTypeVisitorStub {
private final GraphQLCodeRegistry.Builder codeRegistry;
private final GraphQLFieldsContainer containerType;
private final String typeName;

CodeRegistryVisitor(GraphQLCodeRegistry.Builder context,
GraphQLCodeRegistry.Builder codeRegistry,
GraphQLFieldsContainer containerType,
Expand All @@ -240,40 +242,40 @@ class CodeRegistryVisitor extends GraphQLTypeVisitorStub {
}

@Override
public TraversalControl visitGraphQLFieldDefinition(GraphQLFieldDefinition node, TraverserContext<GraphQLType> context) {
public TraversalControl visitGraphQLFieldDefinition(GraphQLFieldDefinition node, TraverserContext<GraphQLSchemaElement> context) {
GraphQLFieldsContainer parentContainerType = (GraphQLFieldsContainer) context.getParentContext().thisNode();
FieldCoordinates coordinates = parentContainerType.equals(containerType) ? coordinates(typeName, node.getName())
FieldCoordinates coordinates = parentContainerType.equals(containerType) ? coordinates(typeName, node.getName())
: coordinates(parentContainerType, node);

DataFetcher<?> dataFetcher = source.getDataFetcher(parentContainerType,
DataFetcher<?> dataFetcher = source.getDataFetcher(parentContainerType,
node);
if (dataFetcher == null) {
dataFetcher = new PropertyDataFetcher<>(node.getName());
}
codeRegistry.dataFetcherIfAbsent(coordinates,

codeRegistry.dataFetcherIfAbsent(coordinates,
dataFetcher);
return CONTINUE;
}

@Override
public TraversalControl visitGraphQLInterfaceType(GraphQLInterfaceType node, TraverserContext<GraphQLType> context) {
public TraversalControl visitGraphQLInterfaceType(GraphQLInterfaceType node, TraverserContext<GraphQLSchemaElement> context) {
TypeResolver typeResolver = codeRegistry.getTypeResolver(node);

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

@Override
public TraversalControl visitGraphQLUnionType(GraphQLUnionType node, TraverserContext<GraphQLType> context) {
public TraversalControl visitGraphQLUnionType(GraphQLUnionType node, TraverserContext<GraphQLSchemaElement> context) {
TypeResolver typeResolver = codeRegistry.getTypeResolver(node);
if (typeResolver != null) {
codeRegistry.typeResolverIfAbsent(node, typeResolver);
}
assertTrue(codeRegistry.getTypeResolver(node) != null, "You MUST provide a type resolver for the union type '" + node.getName() + "'");
assertTrue(codeRegistry.getTypeResolver(node) != null, () -> "You MUST provide a type resolver for the union type '" + node.getName() + "'");
return CONTINUE;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.introproventures.graphql.jpa.query.autoconfigure;

import graphql.PublicApi;
import graphql.schema.GraphQLSchemaElement;
import graphql.schema.GraphQLType;
import graphql.schema.GraphQLTypeVisitor;
import graphql.util.TraversalControl;
import graphql.util.Traverser;
import graphql.util.TraverserContext;
import graphql.util.TraverserResult;
import graphql.util.TraverserVisitor;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

import static graphql.util.TraversalControl.CONTINUE;

class TypeTraverser {


private final Function<? super GraphQLSchemaElement, ? extends List<GraphQLSchemaElement>> getChildren;

public TypeTraverser(Function<? super GraphQLSchemaElement, ? extends List<GraphQLSchemaElement>> getChildren) {
this.getChildren = getChildren;
}

public TypeTraverser() {
this(GraphQLSchemaElement::getChildren);
}

public TraverserResult depthFirst(GraphQLTypeVisitor graphQLTypeVisitor, GraphQLSchemaElement root) {
return depthFirst(graphQLTypeVisitor, Collections.singletonList(root));
}

public TraverserResult depthFirst(final GraphQLTypeVisitor graphQLTypeVisitor, Collection<? extends GraphQLSchemaElement> roots) {
return depthFirst(initTraverser(), new TraverserDelegateVisitor(graphQLTypeVisitor), roots);
}

public TraverserResult depthFirst(final GraphQLTypeVisitor graphQLTypeVisitor,
Collection<? extends GraphQLSchemaElement> roots,
Map<String, GraphQLSchemaElement> types) {
return depthFirst(initTraverser().rootVar(TypeTraverser.class, types), new TraverserDelegateVisitor(graphQLTypeVisitor), roots);
}

public TraverserResult depthFirst(final Traverser<GraphQLSchemaElement> traverser,
final TraverserDelegateVisitor traverserDelegateVisitor,
Collection<? extends GraphQLSchemaElement> roots) {
return doTraverse(traverser, roots, traverserDelegateVisitor);
}

private Traverser<GraphQLSchemaElement> initTraverser() {
return Traverser.depthFirst(getChildren);
}

private TraverserResult doTraverse(Traverser<GraphQLSchemaElement> traverser, Collection<? extends GraphQLSchemaElement> roots, TraverserDelegateVisitor traverserDelegateVisitor) {
return traverser.traverse(roots, traverserDelegateVisitor);
}

private static class TraverserDelegateVisitor implements TraverserVisitor<GraphQLSchemaElement> {
private final GraphQLTypeVisitor before;

TraverserDelegateVisitor(GraphQLTypeVisitor delegate) {
this.before = delegate;

}

@Override
public TraversalControl enter(TraverserContext<GraphQLSchemaElement> context) {
return context.thisNode().accept(context, before);
}

@Override
public TraversalControl leave(TraverserContext<GraphQLSchemaElement> context) {
return CONTINUE;
}

@Override
public TraversalControl backRef(TraverserContext<GraphQLSchemaElement> context) {
return before.visitBackRef(context);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ public void configure(GraphQLShemaRegistration registry) {
.build();

GraphQLSchema graphQLSchema = GraphQLSchema.newSchema()
.query(GraphQLObjectType.newObject().name("null"))
.query(GraphQLObjectType.newObject().name("null")
.field(GraphQLFieldDefinition.newFieldDefinition()
.name("null")
.type(Scalars.GraphQLString)))
.mutation(mutation)
.codeRegistry(codeRegistry)
.build();
Expand Down Expand Up @@ -203,7 +206,7 @@ public void configure(GraphQLShemaRegistration registry) {
GraphQLSchema graphQLSchema = GraphQLSchema.newSchema()
.query(query)
.codeRegistry(codeRegistry)
.additionalDirective(Directives.DeferDirective)
//.additionalDirective(Directives.DeferDirective)
.build();

registry.register(graphQLSchema);
Expand All @@ -223,8 +226,7 @@ public void contextLoads() {
public void directivesSupport() {
assertThat(graphQLSchema.getDirectives())
.extracting(GraphQLDirective::getName)
.containsExactly("include", "skip", "defer");

.containsOnly("include", "skip", "specifiedBy", "deprecated");
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion graphql-jpa-query-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.4.20-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions graphql-jpa-query-build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-dependencies</artifactId>
<version>0.4.20-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-dependencies</relativePath>
</parent>
<artifactId>graphql-jpa-query-build</artifactId>
Expand Down Expand Up @@ -35,7 +35,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.6.6</version>
<version>2.6.12</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions graphql-jpa-query-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query</artifactId>
<version>0.4.20-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>graphql-jpa-query-dependencies</artifactId>
<packaging>pom</packaging>

<properties>
<graphql-java.version>13.0</graphql-java.version>
<graphql-java.version>19.2</graphql-java.version>
<hibernate-jpa-2.1-api.version>1.0.0.Final</hibernate-jpa-2.1-api.version>
<evo-inflector.version>1.2.2</evo-inflector.version>
<javax.interceptor-api.version>1.2.2</javax.interceptor-api.version>
Expand Down
2 changes: 1 addition & 1 deletion graphql-jpa-query-example-merge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.4.20-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.DEFINED_PORT)
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)
public class ApplicationTest {

@Test
Expand Down
2 changes: 1 addition & 1 deletion graphql-jpa-query-example-model-books/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.4.20-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>
<artifactId>graphql-jpa-query-example-model-books</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion graphql-jpa-query-example-model-starwars/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.4.20-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion graphql-jpa-query-example-relay/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.4.20-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions graphql-jpa-query-example-simple/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.4.20-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

Expand Down Expand Up @@ -88,7 +88,7 @@
<goal>push</goal>
</goals>
<configuration>
<pushImage>true</pushImage>
<skipDockerPush>true</skipDockerPush>
</configuration>
</execution>
</executions>
Expand Down
Loading