Skip to content

RBT-928 pass through jakarta annotations #116

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 24 commits into from
Jul 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4f35a65
Refactoring
josie-atkins Mar 3, 2025
603b6dd
tests
josie-atkins Mar 3, 2025
dc120e4
WIP
josie-atkins Mar 12, 2025
b36f3a1
Revert "WIP"
josie-atkins Mar 16, 2025
bbd3c68
Can add Size annotation
josie-atkins Mar 16, 2025
7c63ec6
Tidy
josie-atkins Mar 16, 2025
c340d5a
Add all Jakarta annotations
josie-atkins Mar 17, 2025
5485c54
Merge branch 'master' into RBT-928-pass-through-jakarta-annotations-t…
josie-atkins Mar 17, 2025
0b984e8
Remove unused function
josie-atkins Mar 17, 2025
4d625b6
Fix the tests
josie-atkins Apr 28, 2025
62d8450
Add test for min and max on an integer
josie-atkins Apr 28, 2025
9f35bf3
Add test for a record
josie-atkins Apr 28, 2025
5ea1d0e
Tests pass
josie-atkins May 25, 2025
0debef3
Put validate behinda flag on the SchemaBuilder
josie-atkins May 26, 2025
e6192de
Merge branch 'master' into RBT-928-pass-through-jakarta-annotations-t…
josie-atkins May 26, 2025
0f0b741
Downgrade graphql-java to 22
josie-atkins May 26, 2025
aa7ce9e
formatter
josie-atkins May 26, 2025
23ad41b
Licenses
josie-atkins May 26, 2025
aa6b1cb
Downgrade graphql-java to 22
josie-atkins May 26, 2025
1a2e331
Merge remote-tracking branch 'origin/master' into RBT-928-pass-throug…
josie-atkins Jun 8, 2025
8208742
Downgrade to graphql 22
josie-atkins Jun 8, 2025
ee548da
Revert "Downgrade to graphql 22"
josie-atkins Jul 6, 2025
ad990e6
Merge remote-tracking branch 'origin/master' into RBT-928-pass-throug…
josie-atkins Jul 20, 2025
50e0b05
Upgrade libraries to graphql 24
josie-atkins Jul 20, 2025
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
187 changes: 98 additions & 89 deletions graphql-builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,99 +11,108 @@
the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>graphql-builder</name>
<description>Builds a graphql schema from a model using reflection</description>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>graphql-builder</name>
<description>Builds a graphql schema from a model using reflection</description>

<parent>
<groupId>com.phocassoftware</groupId>
<artifactId>graphql-builder-parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>
<parent>
<groupId>com.phocassoftware</groupId>
<artifactId>graphql-builder-parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>

<artifactId>graphql-builder</artifactId>
<artifactId>graphql-builder</artifactId>

<properties>
<junit.jupiter.version>5.13.0</junit.jupiter.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson.version>2.19.0</jackson.version>
<graphql.version>24.1</graphql.version>
</properties>
<properties>
<junit.jupiter.version>5.13.0</junit.jupiter.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson.version>2.19.0</jackson.version>
<graphql.version>24.1</graphql.version>
</properties>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<dependencies>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>${graphql.version}</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>
<version>21.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.10.2</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.reactivex.rxjava3</groupId>
<artifactId>rxjava</artifactId>
<version>3.1.10</version>
<scope>test</scope>
</dependency>
<dependencies>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>${graphql.version}</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>
<version>24.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-validation</artifactId>
<version>24.0</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.10.2</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.1.0</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<version>1.5.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.reactivex.rxjava3</groupId>
<artifactId>rxjava</artifactId>
<version>3.1.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<version>1.5.3</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@

import com.phocassoftware.graphql.builder.annotations.Directive;
import graphql.introspection.Introspection;
import graphql.schema.*;
import graphql.schema.GraphQLAppliedDirective;
import graphql.schema.GraphQLAppliedDirectiveArgument;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLDirective;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;

Expand All @@ -31,17 +36,26 @@ public DirectiveProcessor(GraphQLDirective directive, Map<String, Function<Objec
this.builders = builders;
}

public static DirectiveProcessor build(EntityProcessor entityProcessor, Class<? extends Annotation> directive) {
public static DirectiveProcessor build(EntityProcessor entityProcessor, Class<? extends Annotation> directive, boolean isJakarta) {
var builder = GraphQLDirective.newDirective().name(directive.getSimpleName());
var validLocations = directive.getAnnotation(Directive.class).value();

Introspection.DirectiveLocation[] validLocations;
if (isJakarta) {
validLocations = new Introspection.DirectiveLocation[] {
Introspection.DirectiveLocation.ARGUMENT_DEFINITION,
Introspection.DirectiveLocation.INPUT_FIELD_DEFINITION };
} else {
validLocations = directive.getAnnotation(Directive.class).value();

// Check for repeatable tag in annotation and add it
builder.repeatable(directive.getAnnotation(Directive.class).repeatable());
}

// loop through and add valid locations
for (Introspection.DirectiveLocation location : validLocations) {
builder.validLocation(location);
}

// Check for repeatable tag in annotation and add it
builder.repeatable(directive.getAnnotation(Directive.class).repeatable());

// Go through each argument and add name/type to directive
var methods = directive.getDeclaredMethods();
Map<String, Function<Object, GraphQLAppliedDirectiveArgument>> builders = new HashMap<>();
Expand Down
Loading
Loading