You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to match type definition (ListType{type=NonNullType{type=TypeName{name='String'}}}) with java type (interface java.util.List): Java class is not a List or generic type information was lost: interface java.util.List #415
I get the following error when starting my application:
...
Caused by: graphql.kickstart.tools.SchemaClassScannerError: Unable to match type definition
(ListType{type=NonNullType{type=TypeName{name='String'}}}) with java type (interface java.util.List):
Java class is not a List or generic type information was lost: interface java.util.List
I suppose this has to do with using List as a generic type.
I'm using graphql-java-tools:6.1.0, the latest version.
Any idea on how to get this data type working in GraphQL? Thanks!
Using Java Array instead of Kotlin List works. However, you lose all the goodness of Kotlin List like deep equality checks etc. In our case this was too painful.
data classTestClass (
valmatch:EntityMatch<Array<String>>
)
Create a copy of the class having the model defined with Array<String> instead of List<String>, and use this class only in the GraphQL layer and do conversions of the data between the application and the GraphQL layer.
store the data as a comma separated list in a single string, and write a wrapper model Matches to work with it
data classTestClass (
valmatch:EntityMatch<Matches>
)
data classMatches (
valmatches:String// comma separated list with matches
)
// create helper functions to create Matches from a List<String>, and to convert Matches into List<String>
In the end we settled with solution (3) which was best for our case.
Fixed by #819: nested type arguments like EntityMatch<List<String>> are no longer erased to the raw List, so value: [String!] now matches. A regression test was added in 349d56a (GenericObjectTypesTest). This ships in 14.0.4.
Activity
vojtapol commentedon Jul 6, 2020
That is not a valid GraphQL schema. Did you mean something like this?
josdejong commentedon Jul 6, 2020
Thanks for your quick reply. Sorry, I tried to simplify the model in this question from a large code base. The actual schema looks like:
Will update the original question to prevent confusion.
josdejong commentedon Jul 13, 2020
FYI: we've tried a few workarounds:
Using Java
Arrayinstead of KotlinListworks. However, you lose all the goodness of KotlinListlike deep equality checks etc. In our case this was too painful.Create a copy of the class having the model defined with
Array<String>instead ofList<String>, and use this class only in the GraphQL layer and do conversions of the data between the application and the GraphQL layer.store the data as a comma separated list in a single string, and write a wrapper model
Matchesto work with itIn the end we settled with solution (3) which was best for our case.
nnrudakov commentedon Mar 25, 2021
Another workaround.
Instead of:
use this:
and in code:
Add regression tests for fixed issues
oryan-block commentedon Oct 3, 2026
Fixed by #819: nested type arguments like
EntityMatch<List<String>>are no longer erased to the rawList, sovalue: [String!]now matches. A regression test was added in 349d56a (GenericObjectTypesTest). This ships in 14.0.4.