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

SmallRye GraphQL conflict with same enum names in different models #12402

Closed
miador opened this issue Sep 29, 2020 · 3 comments · Fixed by #12481
Closed

SmallRye GraphQL conflict with same enum names in different models #12402

miador opened this issue Sep 29, 2020 · 3 comments · Fixed by #12481
Labels
Milestone

Comments

@miador
Copy link

miador commented Sep 29, 2020

SmallRye GraphQL cannot differentiate same enum names in different models from version 1.6.0 to 1.8.1.
We have GraphQL API for banking. We have separate models i.e Accounts and Balances. In Accounts we have an enum called Type and we have enum with same name Type in Balances.

The expected behavior is to see they're working fine as in previous versions.
The quarkus version was 1.5.2 for this apps and we decide to update the quarkus and plug-in versions. In the all versions after 1.5.2, the problem is same. In 1.5.2, it perfectly works without having conflict even if we have same enum name in different models.

Actual behavior
The data is stored in Neo4j and when we run the application, it works fine with accounts. But when running the Balances, it gives the following stacktrace:

2020-09-29 18:51:46,311 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$3.run(StartupActionImpl.java:134)
        at java.base/java.lang.Thread.run(Thread.java:834)
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:60)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
        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:287)
        ... 15 more
Caused by: graphql.AssertException: type can't be null
        at graphql.Assert.assertNotNull(Assert.java:16)
        at graphql.schema.GraphQLFieldDefinition.<init>(GraphQLFieldDefinition.java:85)
        at graphql.schema.GraphQLFieldDefinition$Builder.build(GraphQLFieldDefinition.java:473)
        at io.smallrye.graphql.bootstrap.Bootstrap.createGraphQLFieldDefinitionFromField(Bootstrap.java:399)
        at io.smallrye.graphql.bootstrap.Bootstrap.createGraphQLFieldDefinitionsFromFields(Bootstrap.java:386)
        at io.smallrye.graphql.bootstrap.Bootstrap.createGraphQLObjectType(Bootstrap.java:284)
        at io.smallrye.graphql.bootstrap.Bootstrap.createGraphQLObjectTypes(Bootstrap.java:271)
        at io.smallrye.graphql.bootstrap.Bootstrap.generateGraphQLSchema(Bootstrap.java:123)
        at io.smallrye.graphql.bootstrap.Bootstrap.bootstrap(Bootstrap.java:103)
        at io.smallrye.graphql.cdi.producer.GraphQLProducer.initialize(GraphQLProducer.java:41)
        at io.smallrye.graphql.cdi.producer.GraphQLProducer.initialize(GraphQLProducer.java:37)
        at io.smallrye.graphql.cdi.producer.GraphQLProducer_ClientProxy.initialize(GraphQLProducer_ClientProxy.zig:185)
        at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLRecorder.createExecutionService(SmallRyeGraphQLRecorder.java:24)
        at io.quarkus.deployment.steps.SmallRyeGraphQLProcessor$buildExecutionService-1556698146.deploy_2(SmallRyeGraphQLProcessor$buildExecutionService-1556698146.zig:5278)
        at io.quarkus.deployment.steps.SmallRyeGraphQLProcessor$buildExecutionService-1556698146.deploy(SmallRyeGraphQLProcessor$buildExecutionService-1556698146.zig:50)
        at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:267)

To Reproduce
Steps to reproduce the behavior:

  1. Create 2 separate models.
  2. Have an enum type in both models with same enum name.(i.e enum Type in Accounts and Balances)
  3. Run it in debug mode, put the breakpoint on line 85 in GraphQLFieldDefinition.java and see the hitting type can't be null on same enum name.

Environment (please complete the following information):

  • MSYS_NT-10.0-19041 DESKTOP-6RLSJFU 3.0.7-338.x86_64 2019-11-21 23:07 UTC x86_64 Msys
  • Output of java -version: openjdk version "11.0.7" 2020-04-14
  • GraalVM version (if different from Java): OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
  • Quarkus version or git rev: 1.8.1
  • Apache Maven 3.6.3

Additional context
If you really want to see that's the reason, you can simply create other models as well and have same enum name. It will hit on that and will say type can't be null

Regards!
Yusuf

@miador miador added the kind/bug Something isn't working label Sep 29, 2020
@quarkusbot
Copy link

@gsmet
Copy link
Member

gsmet commented Sep 29, 2020

Please create a small Maven reproducer, it's really far easier for us to reproduce issues that way.

Thanks!

@phillip-kruger
Copy link
Member

@miador - yes a reproducer will help. As a workaround you can try and give the types unique names using the Enum annotation:
Something like:

@Enum("AccountType") and @Enum("BalanceType") (as a class level annotation on the enum)

see https://download.eclipse.org/microprofile/microprofile-graphql-1.0.2/microprofile-graphql.html#enums

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

Successfully merging a pull request may close this issue.

4 participants