Skip to content
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

CustomDirective for smallrye-graphql does not work #20802

Closed
johgoe opened this issue Oct 15, 2021 · 7 comments
Closed

CustomDirective for smallrye-graphql does not work #20802

johgoe opened this issue Oct 15, 2021 · 7 comments
Labels

Comments

@johgoe
Copy link

johgoe commented Oct 15, 2021

Describe the bug

It seems that types of custom directive annotations are not added to the deployment, which causes an error on startup, if the directive is used in a entity.

import io.smallrye.graphql.api.Directive;
import io.smallrye.graphql.api.DirectiveLocation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.eclipse.microprofile.graphql.NonNull;

@Directive(
    on = {DirectiveLocation.OBJECT, DirectiveLocation.INTERFACE}
)
@Retention(RetentionPolicy.RUNTIME)
public @interface CustomDirective{
    @NonNull
    String[] fields();
}

I'm not familar with quarkus extensions but it seems that in SmallRyeGraphQLProcessor getSchemaJavaClasses() all Types which are used in Schema are added except the Types of the Directive. I guess a single line like

classes.addAll(getTypeClassNames(schema.getDirectiveTypes()));

will fix my problem.

Expected behavior

Quarkus is starting even if I use custom directives within my GraphQL API

Actual behavior

2021-10-15 19:14:36,357 INFO  [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure
2021-10-15 19:14:36,358 ERROR [io.qua.run.boo.StartupActionImpl] (Quarkus Main Thread) Error running Quarkus: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:98)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.ExceptionInInitializerError
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at java.base/java.lang.Class.newInstance(Class.java:584)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:65)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
	... 6 more
Caused by: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:470)
	... 15 more
Caused by: java.lang.UnsupportedOperationException
	at java.base/java.util.AbstractCollection.add(AbstractCollection.java:267)
	at io.quarkus.deployment.steps.SmallRyeGraphQLProcessor$buildExecutionService-167583418.deploy_2(SmallRyeGraphQLProcessor$buildExecutionService-167583418.zig:5725)
	at io.quarkus.deployment.steps.SmallRyeGraphQLProcessor$buildExecutionService-167583418.deploy(SmallRyeGraphQLProcessor$buildExecutionService-167583418.zig:50)
	at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:439)
	... 15 more

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.3

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@johgoe johgoe added the kind/bug Something isn't working label Oct 15, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 15, 2021

@johgoe
Copy link
Author

johgoe commented Oct 21, 2021

I attached a sample project to reproduce the issue

quarkus-sample-20802-main.zip

(or you look into my sample repo https://github.com/johgoe/quarkus-sample-20802/blob/main/src/main/java/org/acme/ )

@phillip-kruger
Copy link
Member

Hi @johgoe - Thanks for this. Yes we are still working to get this into Quarkus. We expect to have it in soon.

@gsmet
Copy link
Member

gsmet commented Jan 5, 2022

@phillip-kruger was it implemented somehow or it's still pending?

@phillip-kruger
Copy link
Member

Not yet. On my todo list...

@uetal
Copy link

uetal commented Jul 7, 2022

hi @phillip-kruger it's still pending?

@phillip-kruger
Copy link
Member

still pending. PRs welcomed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants