Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ClassCastException not very helpful when misconfigured either schema or resolver #289

Closed
XanderAtBackboneSystems opened this issue Jul 9, 2019 · 1 comment

Comments

@XanderAtBackboneSystems
Copy link

XanderAtBackboneSystems commented Jul 9, 2019

When i tried to return a Connection in a resolver which would be coupled to a simple list type in the graphql schema (which is evidently wrong) i got the following error which is not very helpful.

java.lang.ClassCastException: com.coxautodev.graphql.tools.ParameterizedTypeImpl cannot be cast to java.lang.Class

I suppose a better detection and a better error message would be helpful when making this kind of errors.

using the following
graphql-java version: 13.0
graphql-java-tools version: 5.6.1

To reproduce:

schema:

type Query {
   findBlips: [Blip!]!
}

type Blip {
 foo: String
 bar: String 
}

resolver

public class QueryResolver implements GraphQLQueryResolver {
    public Connection<Blip> findBlips(DataFetchingEnvironment env) {
        List<Blip> blips = findBlips();
        return new SimpleListConnection<>(blips).get(env);
    }
}

Hope you can improve the error...

The stack trace is:

java.lang.ClassCastException: com.coxautodev.graphql.tools.ParameterizedTypeImpl cannot be cast to java.lang.Class
	at com.coxautodev.graphql.tools.TypeClassMatcher.match(TypeClassMatcher.kt:81)
	at com.coxautodev.graphql.tools.TypeClassMatcher.match$default(TypeClassMatcher.kt:32)
	at com.coxautodev.graphql.tools.TypeClassMatcher.match(TypeClassMatcher.kt:75)
	at com.coxautodev.graphql.tools.TypeClassMatcher.match(TypeClassMatcher.kt:28)
	at com.coxautodev.graphql.tools.SchemaClassScanner.scanResolverInfoForPotentialMatches(SchemaClassScanner.kt:268)
	at com.coxautodev.graphql.tools.SchemaClassScanner.handleRootType(SchemaClassScanner.kt:119)
	at com.coxautodev.graphql.tools.SchemaClassScanner.scanForClasses(SchemaClassScanner.kt:77)
	at com.coxautodev.graphql.tools.SchemaParserBuilder.scan(SchemaParserBuilder.kt:165)
	at com.coxautodev.graphql.tools.SchemaParserBuilder.build(SchemaParserBuilder.kt:206)
	<removed>
@oryan-block
Copy link
Collaborator

Fixed in #754

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

No branches or pull requests

2 participants