1 year ago
#362584
Monjur Morshed
unsatisfiable cycle and "ObjectIdInput" related exception in Quarkus GraphQL
I am developing a project with Quarkus and mongodb. I have a model as below.
@MongoEntity(collection = "Designation")
public class Designation extends ReactivePanacheMongoEntityBase {
@AdaptToScalar(Scalar.String.class)
public ObjectId id;
@NotBlank(message = "Name must not be blank")
public String name;
@NotBlank(message = "Short name must not be blank")
public String shortName;
@NotBlank(message = "Grade must not be blank")
public Integer grade;
public Designation bn;
}
The model has two parts, name,shortName, grade are for English language, and bn is for Bangla language and it's of type Designation as it has the same properties like name, shortName and grade.
I have a graphql resource as below.
@GraphQLApi
public class DesignationGResource {
@Query("designations")
@Description("Get all designations")
public Uni<List<Designation>> getAllDesignations(){
return Designation.listAll();
}
@Query("designation")
@Description("Get designation by id")
public Uni<Designation> getDesignationById(@Name("designationId") String designationId){
return Designation.findById(new ObjectId(designationId));
}
@Mutation
public Uni<Designation> saveDesignation(Designation designation){
return designation.persist();
}
}
Here Query is working fine. But the saveDesignation() mutation is not working and throwing two exceptions, one for ObjectId: "ObjectIdInput" must define one or more fields and one for unsatisfiable cycle: [bn!] forms an unsatisfiable cycle and the full exception message is shown here:
Caused by: graphql.schema.validation.InvalidSchemaException: invalid schema:
[bn!] forms an unsatisfiable cycle
"ObjectIdInput" must define one or more fields.
at graphql.schema.GraphQLSchema$Builder.validateSchema(GraphQLSchema.java:828)
at graphql.schema.GraphQLSchema$Builder.buildImpl(GraphQLSchema.java:822)
at graphql.schema.GraphQLSchema$Builder.build(GraphQLSchema.java:787)
at io.smallrye.graphql.bootstrap.Bootstrap.generateGraphQLSchema(Bootstrap.java:186)
at io.smallrye.graphql.bootstrap.Bootstrap.bootstrap(Bootstrap.java:113)
at io.smallrye.graphql.bootstrap.Bootstrap.bootstrap(Bootstrap.java:107)
at io.smallrye.graphql.cdi.producer.GraphQLProducer.initialize(GraphQLProducer.java:34)
at io.smallrye.graphql.cdi.producer.GraphQLProducer_Subclass.initialize$$superforward1(Unknown Source)
at io.smallrye.graphql.cdi.producer.GraphQLProducer_Subclass$$function$$2.apply(Unknown Source)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:51)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
at io.smallrye.graphql.cdi.producer.GraphQLProducer_Subclass.initialize(Unknown Source)
at io.smallrye.graphql.cdi.producer.GraphQLProducer.initialize(GraphQLProducer.java:29)
at io.smallrye.graphql.cdi.producer.GraphQLProducer_Subclass.initialize$$superforward1(Unknown Source)
at io.smallrye.graphql.cdi.producer.GraphQLProducer_Subclass$$function$$4.apply(Unknown Source)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:51)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
at io.smallrye.graphql.cdi.producer.GraphQLProducer_Subclass.initialize(Unknown Source)
at io.smallrye.graphql.cdi.producer.GraphQLProducer.initialize(GraphQLProducer.java:24)
at io.smallrye.graphql.cdi.producer.GraphQLProducer_Subclass.initialize$$superforward1(Unknown Source)
at io.smallrye.graphql.cdi.producer.GraphQLProducer_Subclass$$function$$3.apply(Unknown Source)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:51)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
at io.smallrye.graphql.cdi.producer.GraphQLProducer_Subclass.initialize(Unknown Source)
at io.smallrye.graphql.cdi.producer.GraphQLProducer_ClientProxy.initialize(Unknown Source)
at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLRecorder.createExecutionService(SmallRyeGraphQLRecorder.java:31)
at io.quarkus.deployment.steps.SmallRyeGraphQLProcessor$buildExecutionService259019385.deploy_1(Unknown Source)
at io.quarkus.deployment.steps.SmallRyeGraphQLProcessor$buildExecutionService259019385.deploy(Unknown Source)
at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347)
at java.base/java.lang.Class.newInstance(Class.java:645)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
at io.quarkus.runner.GeneratedMain.main(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
at java.base/java.lang.Thread.run(Thread.java:833)
Currently, I am handling the mutation using below code.
@Mutation("createDesignation")
@Description("Create designation")
public Uni<Designation> createDesignation(String name,String shortName,Integer grade,String bnName,String bnShortName){
Designation designation = new Designation();
designation.name = name;
designation.shortName = shortName;
designation.grade = grade;
designation.bn = new Designation();
designation.bn.name = bnName;
designation.bn.shortName = bnShortName;
return designation.persist();
}
But is there any way to handle the above ObjectId and unsatisfiable cycle exception?
mongodb
quarkus
graphql-java
quarkus-panache
0 Answers
Your Answer