Skip to content

Commit 0ba989a

Browse files
Merge pull request #149 from phocassoftware/make-work-with-java-25
make work with java 25
2 parents 8524102 + 9070686 commit 0ba989a

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

graphql-builder/src/main/java/com/phocassoftware/graphql/builder/DirectiveProcessor.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public static DirectiveProcessor build(EntityProcessor entityProcessor, Class<?
6363
if (method.getParameterCount() != 0) {
6464
continue;
6565
}
66+
if (!validResponseType(method.getReturnType())) {
67+
continue;
68+
}
6669
var name = method.getName();
6770

6871
GraphQLArgument.Builder argument = GraphQLArgument.newArgument();
@@ -92,6 +95,16 @@ public static DirectiveProcessor build(EntityProcessor entityProcessor, Class<?
9295
return new DirectiveProcessor(builder.build(), builders);
9396
}
9497

98+
private static boolean validResponseType(Class<?> returnType) {
99+
if (returnType.isArray()) {
100+
return validResponseType(returnType.getComponentType());
101+
}
102+
if (returnType.equals(Class.class)) {
103+
return false;
104+
}
105+
return true;
106+
}
107+
95108
public void apply(Annotation annotation, Consumer<GraphQLAppliedDirective> builder) throws InvocationTargetException, IllegalAccessException {
96109
var methods = annotation.annotationType().getDeclaredMethods();
97110

@@ -101,6 +114,9 @@ public void apply(Annotation annotation, Consumer<GraphQLAppliedDirective> build
101114

102115
// To get the value we loop through each method and get the method name and value
103116
for (Method m : methods) {
117+
if (!validResponseType(m.getReturnType())) {
118+
continue;
119+
}
104120
// Using the builder created earlier populate the values of each method.
105121
arguments.argument(builders.get(m.getName()).apply(annotation));
106122
}

graphql-builder/src/test/java/com/phocassoftware/graphql/builder/JakartaValidationDirectiveTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ void testJakartaSizeDirectiveArgumentDefinition() {
5656
assertEquals(32, dir.size());
5757
assertEquals("ARGUMENT_DEFINITION", ((List<String>) constraint.get("locations")).get(0));
5858
assertEquals("INPUT_FIELD_DEFINITION", ((List<String>) constraint.get("locations")).get(1));
59-
assertEquals(5, ((List<Object>) constraint.get("args")).size());
60-
assertEquals("{name=payload}", ((List<Object>) constraint.get("args")).getFirst().toString());
61-
assertEquals("{name=min}", ((List<Object>) constraint.get("args")).get(1).toString());
62-
assertEquals("{name=max}", ((List<Object>) constraint.get("args")).get(2).toString());
63-
assertEquals("{name=message}", ((List<Object>) constraint.get("args")).get(3).toString());
64-
assertEquals("{name=groups}", ((List<Object>) constraint.get("args")).get(4).toString());
59+
assertEquals(3, ((List<Object>) constraint.get("args")).size());
60+
assertEquals("{name=min}", ((List<Object>) constraint.get("args")).get(0).toString());
61+
assertEquals("{name=max}", ((List<Object>) constraint.get("args")).get(1).toString());
62+
assertEquals("{name=message}", ((List<Object>) constraint.get("args")).get(2).toString());
6563
}
6664

6765
@Test

graphql-builder/src/test/java/com/phocassoftware/graphql/builder/type/directive/Admin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
public @interface Admin {
2828
String value();
2929

30+
Class<?>[] toIgnore() default {};
31+
3032
static class Processor implements DirectiveCaller<Admin> {
3133

3234
@Override

0 commit comments

Comments
 (0)