GraphQLResolver throws "Value already present: Pojo.class"

Viewed 649

This is the relevant bit in my GraphQL Schema:

type pojo {
    details: detailspojo,
    name: String,
    method: String,
    ext_Path: String,
    int_Path: String,
    mle: String
}

type detailspojo{
 address
}

My use case requires me to fetch all details except detailspojo from a database query and detailspojo from an HTTP request.

I've built a class which implements GraphQLQueryResolver, where all the fields are queried from the database. I've built below class which implements GraphQLResolver<pojo>, where pojo is a DTO for my pojo schema.

@Component
public class detailsresolver implements GraphQLResolver<pojo> {
    public detailspojo getOperationalSummary(Pojo pojo) {
// Here I will be making HTTP request to get data.
        return null;
    }
}

I've made all the appropriate POJOs. I've seen all tutorials relevant to GraphQLResolver<T>, and I seem to have done everything. Still I get this error:

Caused by: graphql.kickstart.tools.SchemaClassScannerError: Error creating bimap of type => class
    at graphql.kickstart.tools.SchemaClassScanner.validateAndCreateResult(SchemaClassScanner.kt:157) ~[graphql-java-tools-11.0.1.jar:na]
    at graphql.kickstart.tools.SchemaClassScanner.scanForClasses(SchemaClassScanner.kt:104) ~[graphql-java-tools-11.0.1.jar:na]
    at graphql.kickstart.tools.SchemaParserBuilder.scan(SchemaParserBuilder.kt:154) ~[graphql-java-tools-11.0.1.jar:na]
    at graphql.kickstart.tools.SchemaParserBuilder.build(SchemaParserBuilder.kt:195) ~[graphql-java-tools-11.0.1.jar:na]
    at graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration.schemaParser(GraphQLJavaToolsAutoConfiguration.java:125) ~[graphql-kickstart-spring-boot-autoconfigure-tools-11.1.0.jar:na]
    at graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration$$EnhancerBySpringCGLIB$$a945e683.CGLIB$schemaParser$4(<generated>) ~[graphql-kickstart-spring-boot-autoconfigure-tools-11.1.0.jar:na]
    at graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration$$EnhancerBySpringCGLIB$$a945e683$$FastClassBySpringCGLIB$$ab7f3bb9.invoke(<generated>) ~[graphql-kickstart-spring-boot-autoconfigure-tools-11.1.0.jar:na]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration$$EnhancerBySpringCGLIB$$a945e683.schemaParser(<generated>) ~[graphql-kickstart-spring-boot-autoconfigure-tools-11.1.0.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_291]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_291]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_291]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_291]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    ... 144 common frames omitted

Caused by: java.lang.IllegalArgumentException: value already present: class com.example.project.Pojo

Please let me know what to do, I'm willing to add more information if it'd help. Thanks!

Edit 1: I'm using the following Maven packages:

        <dependency>
            <groupId>com.graphql-java-kickstart</groupId>
            <artifactId>graphql-spring-boot-starter</artifactId>
            <version>11.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.graphql-java-kickstart</groupId>
            <artifactId>playground-spring-boot-starter</artifactId>
            <version>7.1.0</version>
        </dependency>
1 Answers

This is an older question but it hit me today and I managed to resolve it - in my case, I had two queries in my schema definition that returned different SCHEMA types, but the same JAVA types - once I remedied that (the Java types were supposed to be different), everything worked like magic.

Hope that helps the next guy...

Related