Skip to content

Commit

Permalink
Merge branch 'main' into namespace
Browse files Browse the repository at this point in the history
# Conflicts:
#	client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/OperationModel.java
  • Loading branch information
Roman Lovakov committed Sep 11, 2024
2 parents 10c16d2 + eb2b6db commit eb9df1a
Show file tree
Hide file tree
Showing 37 changed files with 130 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/project.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: SmallRye GraphQL
release:
current-version: 2.9.2
next-version: 2.9.3-SNAPSHOT
current-version: 2.10.0
next-version: 2.10.1-SNAPSHOT
2 changes: 1 addition & 1 deletion client/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/generator-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-generator-test</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-generator</artifactId>
Expand Down
31 changes: 30 additions & 1 deletion client/implementation-vertx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-implementation-vertx</artifactId>
Expand Down Expand Up @@ -71,4 +71,33 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<!--This configuration separates the execution of the `TypesafeTckClientModelSuite` tests
from the default test execution (TypesafeTckSuite) to avoid conflicts or issues that might
arise when executing the same tests multiple times in different test suites.-->
<id>default-test</id>
<configuration>
<excludes>TypesafeTckClientModelSuite</excludes>
</configuration>
</execution>
<execution>
<id>separate-execution-for-client-model-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<test>TypesafeTckClientModelSuite</test>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class TypesafeTckClientModelSuite extends TypesafeTCK {
static void beforeAll() {
// These properties are for the ‘TypesafeGraphQLClientBuilder#builder’ to differentiate between the typesafe-client
// using the client model and the one that does not.

System.clearProperty("clientModelCase");
System.setProperty("clientModelCase", "true");
}
Expand Down
2 changes: 1 addition & 1 deletion client/implementation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/model-builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-model-builder</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ private static Map<DotName, AnnotationInstance> getAnnotationsWithFilter(Type ty
public static final DotName JAKARTA_JSONB_TRANSIENT = DotName.createSimple(JAKARTA_JSONB + "JsonbTransient");
public static final DotName JAKARTA_JSONB_CREATOR = DotName.createSimple(JAKARTA_JSONB + "JsonbCreator");
public static final DotName JAKARTA_JSONB_TYPE_ADAPTER = DotName.createSimple(JAKARTA_JSONB + "JsonbTypeAdapter");
public static final DotName JAKARTA_JSONB_TYPE_INFO = DotName.createSimple(JAKARTA_JSONB + "JsonbTypeInfo");

// Jackson Annotations
public static final DotName JACKSON_IGNORE = DotName.createSimple("com.fasterxml.jackson.annotation.JsonIgnore");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ public static boolean isAsync(Type type) {
|| isMulti(type);
}

public static boolean isInterface(Type type) {
if (Classes.isClass(type)) {
ClassInfo clazz = getIndex().getClassByName(type.asClassType().name());
return clazz != null && clazz.isInterface();
}
return false;
}

public static boolean isUni(Type type) {
return type.name().equals(UNI);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static java.util.stream.Collectors.toList;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.Stack;
Expand Down Expand Up @@ -104,6 +105,13 @@ public String recursionCheckedFields(TypeModel type) {
String valueFields = fields(type.getMapValueType());
return " {key" + keyFields + " value" + valueFields + "}";
}
if (type.isUnion() || type.isInterface()) {
return "{__typename " + type.subtypes()
.sorted(Comparator.comparing(TypeModel::getGraphQlTypeName)) // for deterministic order
.map(this::fieldsFragment)
.collect(joining(" ")) +
"}";
}
if (isRawParametrizedType(type)) {
rawParametrizedTypes.push(type.getFirstRawType());
}
Expand Down Expand Up @@ -445,4 +453,8 @@ public String getOperationName(boolean useNamespace) {
private String makeFirstLetterUppercase(String value) {
return value.substring(0, 1).toUpperCase() + value.substring(1);
}

private String fieldsFragment(TypeModel type) {
return "... on " + type.getGraphQlTypeName() + fields(type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import static io.smallrye.graphql.client.model.Annotations.IGNORE;
import static io.smallrye.graphql.client.model.Annotations.JACKSON_IGNORE;
import static io.smallrye.graphql.client.model.Annotations.JAKARTA_JSONB_TRANSIENT;
import static io.smallrye.graphql.client.model.Annotations.JAKARTA_JSONB_TYPE_INFO;
import static io.smallrye.graphql.client.model.Annotations.TYPE;
import static io.smallrye.graphql.client.model.Annotations.UNION;
import static io.smallrye.graphql.client.model.Classes.ERROR_OR;
import static io.smallrye.graphql.client.model.Classes.OBJECT;
import static io.smallrye.graphql.client.model.Classes.OPTIONAL;
Expand All @@ -20,6 +23,7 @@

import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.FieldInfo;
Expand Down Expand Up @@ -361,6 +365,21 @@ public boolean isTypeVariable() {
return Classes.isTypeVariable(type);
}

/**
* @see <a href="https://spec.graphql.org/draft/#sec-Unions">GraphQL Union</a>
*/
public boolean isUnion() {
return type.hasAnnotation(UNION);
}

/**
* Is this a <em>GraphQL</em> Interface, i.e. a Java interface without a <code>&#64;Union</code> annotation.
*
*/
public boolean isInterface() {
return Classes.isInterface(type) && !isUnion();
}

/**
* Retrieves a stream of FieldModel instances representing the fields of the type.
*
Expand Down Expand Up @@ -477,4 +496,32 @@ public boolean isCustomParametrizedType() {
&& !isMap()
&& !isCollection();
}

public String getGraphQlTypeName() {
Optional<AnnotationInstance> annotationInstance = getClassAnnotation(TYPE);
if (annotationInstance.isPresent()) {
AnnotationValue value = annotationInstance.get().value();
if (value != null) {
return value.asString();
}
}
return getSimpleName();
}

/**
* Retrieves the subtypes of the current class based on the `JsonbTypeInfo` annotation.
*
* @return A stream of subtype models.
*/
public Stream<TypeModel> subtypes() {
Optional<AnnotationInstance> jsonbTypeInfoAnnotation = getClassAnnotation(JAKARTA_JSONB_TYPE_INFO);
if (jsonbTypeInfoAnnotation.isEmpty()) {
return Stream.empty();
}

return Stream.of(jsonbTypeInfoAnnotation.get().value().asNestedArray())
.map(annotationInstance -> annotationInstance.value("type"))
.map(AnnotationValue::asClass)
.map(TypeModel::of);
}
}
2 changes: 1 addition & 1 deletion client/model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-model</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-parent</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-tck</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-common-parent</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion common/schema-builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-common-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-schema-builder</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion common/schema-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-common-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-schema-model</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-documentation</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>smallrye-graphql-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>

<packaging>pom</packaging>
<name>SmallRye: GraphQL Parent</name>
Expand Down
2 changes: 1 addition & 1 deletion release/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-release</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion server/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-server-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion server/implementation-cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-server-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-cdi</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion server/implementation-servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-server-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-servlet</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion server/implementation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-server-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion server/integration-tests-jdk16/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>smallrye-graphql-server-parent</artifactId>
<groupId>io.smallrye</groupId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion server/integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-server-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-server-parent</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion server/runner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-server-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-runner</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion server/tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-server-parent</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.10.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-tck</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tools/gradle-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2.9.2
version=2.10.0
Loading

0 comments on commit eb9df1a

Please sign in to comment.