graphql-java-tools icon indicating copy to clipboard operation
graphql-java-tools copied to clipboard

com.coxautodev.graphql.tools.ResolverError: Expected source object to be an instance of 'com.xxxx.graphql.Query' but instead got 'java.lang.Object'

Open peterdelahunty opened this issue 7 years ago • 2 comments

Hi guys

Amazing Library you have created, thank you so much. I've been using it on a project just fine for weeks with the following config

springBootVersion = '1.5.10.RELEASE' compile('com.graphql-java:graphql-spring-boot-starter:3.6.0') compile('com.graphql-java:graphql-java-tools:3.2.0') compile('org.codehaus.groovy:groovy-all')

However when i try to upgrade to Spring 2 i get the following error

com.coxautodev.graphql.tools.ResolverError: Expected source object to be an instance of 'com.xxxx.graphql.Query' but instead got 'java.lang.Object'

This is the configuration i am using with groovy springBootVersion = '2.0.2.RELEASE' compile('com.graphql-java:graphql-spring-boot-starter:4.2.0') compile('com.graphql-java:graphql-java-tools:5.1.0') compile('org.codehaus.groovy:groovy')

Any ideas what is causing this. I have not changed any of the graphql configuration ?

peterdelahunty avatar Jun 14 '18 14:06 peterdelahunty

I have narrowed the problems down

Looks like i cannot do this anymore

@Component
class Query implements GraphQLQueryResolver {

}

@Component
class Mutation implements GraphQLMutationResolver {

    @Autowired
    Query query
    
    Query createUser(UserInput userInput) {
        userService.createuser(userInput)
        return query
    }

}

Notice i autowire the Query into the Mutation and return it on the Mutation call. I have it setup like this so I can do run another query on the response from my mutation. It is very usefull.

Use to work in old version now it does not work. If I do this my Query object gets mapped as a ResolverInfo of type DataClassResolverInfo instead of a RootResolverInfo. So line SchemaClassScanner of 181 prints out this error:

Root query resolver was provided but no methods on it were used in data fetchers for GraphQL type 'Query'! Either remove the com.coxautodev.graphql.tools.GraphQLQueryResolver interface from the resolver or remove the resolver entirely: com.xxxx.graphql.Query@437e21d5

peterdelahunty avatar Jun 15 '18 04:06 peterdelahunty

Hi, I encountered a very similar problem. Have you managed to solve this somehow?

barucden avatar Aug 23 '18 14:08 barucden

I don't think nesting the top level types like that is supported. Closing for now.

oryan-block avatar Jul 21 '23 17:07 oryan-block