schema-generation using Java classes #1149
-
Hi, I would like to use Java classes for types as it is a shared library with other systems. It is working in a sense that I can generate a schema and the type is used for that, even though it has a Is there a setting that we can use for that? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hello 👋 We rely on KType.isMarkedNullable to determine whether a field is nullable or not. Based on the docs if you annotate your Java classes with appropriate annotations (such as
*since we rely on reflections there might be some other issues caused by differences between Java and Kotlin |
Beta Was this translation helpful? Give feedback.
-
@huehnerlady Java types are considered platform types which yes means they are neither nullable nor non-nullable (see the link doc for details). I just tried the annotation approach specified in the KType.isMarkedNullable and it works fine if you use annotations with runtime retention (i.e. See https://github.com/dariuszkuc/graphql-kotlin-java-models which correctly generate type Foo {
getBar: String!
getBaz: Int
} from corresponding Java model. |
Beta Was this translation helpful? Give feedback.
@huehnerlady Java types are considered platform types which yes means they are neither nullable nor non-nullable (see the link doc for details). I just tried the annotation approach specified in the KType.isMarkedNullable and it works fine if you use annotations with runtime retention (i.e.
spotbugs-annotations
).See https://github.com/dariuszkuc/graphql-kotlin-java-models which correctly generate
from corresponding Java model.