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

Unable to match type definition (List?) using latest Java Tools 5.4 #209

Closed
marceloverdijk opened this issue Nov 21, 2018 · 4 comments
Closed

Comments

@marceloverdijk
Copy link

I was trying to upgrade the Spring Boot Starter from 5.1 to 5.2 but got a schema parser error.
It's a kotlin project containing:

type Query {
    season(year: Int!): Season
    seasons(first: Int = 10, offset: Int = 0): SeasonPage!
}

The GraphQLQueryResolver contains:

    fun season(year: Int): Season? {
        return seasonRepository.findByYear(year)
    }

    fun seasons(first: Int, offset: Int, environment: DataFetchingEnvironment): Page<Season> {
        val sort = Sort.by("year").descending()
        val seasons = if (isItemsSelected(environment)) seasonRepository.findAll(first, offset, sort) else null
        val totalCount = if (isPageInfoSelected(environment)) seasonRepository.count() else null
        return createPage(seasons, totalCount, first, offset)
    }

where Page is a simple Kotlin data class:

data class Page<T>(
        val items: List<T>?,
        val hasNextPage: Boolean?,
        val hasPreviousPage: Boolean?,
        val totalCount: Long?
)

now when I run the app I get suddenly:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.coxautodev.graphql.tools.SchemaParser]: Factory method 'schemaParser' threw exception; nested exception is com.coxautodev.graphql.tools.SchemaClassScannerError: Unable to match type definition (NonNullType{type=ListType{type=NonNullType{type=TypeName{name='Season'}}}}) with java type (interface java.util.List): Java class is not a List or generic type information was lost: interface java.util.List
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:620) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE]
        ... 123 common frames omitted
Caused by: com.coxautodev.graphql.tools.SchemaClassScannerError: Unable to match type definition (NonNullType{type=ListType{type=NonNullType{type=TypeName{name='Season'}}}}) with java type (interface java.util.List): Java class is not a List or generic type information was lost: interface java.util.List
        at com.coxautodev.graphql.tools.TypeClassMatcher.error(TypeClassMatcher.kt:22) ~[graphql-java-tools-5.4.0.jar:na]
        at com.coxautodev.graphql.tools.TypeClassMatcher.match(TypeClassMatcher.kt:82) ~[graphql-java-tools-5.4.0.jar:na]
        at com.coxautodev.graphql.tools.TypeClassMatcher.match$default(TypeClassMatcher.kt:32) ~[graphql-java-tools-5.4.0.jar:na]
        at com.coxautodev.graphql.tools.TypeClassMatcher.match(TypeClassMatcher.kt:75) ~[graphql-java-tools-5.4.0.jar:na]
        at com.coxautodev.graphql.tools.TypeClassMatcher.match(TypeClassMatcher.kt:28) ~[graphql-java-tools-5.4.0.jar:na]
        at com.coxautodev.graphql.tools.SchemaClassScanner.scanResolverInfoForPotentialMatches(SchemaClassScanner.kt:261) ~[graphql-java-tools-5.4.0.jar:na]
        at com.coxautodev.graphql.tools.SchemaClassScanner.scanQueueItemForPotentialMatches(SchemaClassScanner.kt:244) ~[graphql-java-tools-5.4.0.jar:na]
        at com.coxautodev.graphql.tools.SchemaClassScanner.scanQueue(SchemaClassScanner.kt:105) ~[graphql-java-tools-5.4.0.jar:na]
        at com.coxautodev.graphql.tools.SchemaClassScanner.scanForClasses(SchemaClassScanner.kt:83) ~[graphql-java-tools-5.4.0.jar:na]
        at com.coxautodev.graphql.tools.SchemaParserBuilder.scan(SchemaParserBuilder.kt:163) ~[graphql-java-tools-5.4.0.jar:na]
        at com.coxautodev.graphql.tools.SchemaParserBuilder.build(SchemaParserBuilder.kt:204) ~[graphql-java-tools-5.4.0.jar:na]
        at com.oembedler.moon.graphql.boot.GraphQLJavaToolsAutoConfiguration.schemaParser(GraphQLJavaToolsAutoConfiguration.java:101) ~[graphql-spring-boot-autoconfigure-5.2.jar:na]
        at com.oembedler.moon.graphql.boot.GraphQLJavaToolsAutoConfiguration$$EnhancerBySpringCGLIB$$a4aea0aa.CGLIB$schemaParser$1(<generated>) ~[graphql-spring-boot-autoconfigure-5.2.jar:na]
        at com.oembedler.moon.graphql.boot.GraphQLJavaToolsAutoConfiguration$$EnhancerBySpringCGLIB$$a4aea0aa$$FastClassBySpringCGLIB

it is working in 5.1.
Maybe there is a regression in Java Tools 5.4.0?

@marceloverdijk
Copy link
Author

I will try to create a unit test later.

@marceloverdijk
Copy link
Author

Probably related / similar as #208

@liqweed
Copy link

liqweed commented Nov 21, 2018

We experienced this exact regression upgrading from v5.3.5 to v5.4.0.

@varahash
Copy link
Contributor

This is regression after #201, I will provide fix for this.

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

No branches or pull requests

3 participants