I have a query where I want to give as input a nested structure of a shopping cart object. I also defined the very same structure as data classes in Kotlin.
This is the schema.graphqls:
type Query {
calculatePalletDeliveryCosts(input: ShoppingCartInput): Int
}
input ShoppingCartInput {
products: [ShoppingCartProductInput!]!,
}
input ShoppingCartProductInput {
productOrderDetails: ProductOrderDetailsInput
}
input ProductOrderDetailsInput {
orderUnits: [OrderUnitInput]
quantity: Float!
}
input OrderUnitInput {
code: String!
}
And this these are the corresponding classes:
data class ShoppingCartInput (
val products: List<ShoppingCartProductInput>,
)
data class ShoppingCartProductInput(
val productOrderDetails: ProductOrderDetailsInput
)
data class ProductOrderDetailsInput(
val orderUnit: OrderUnitInput,
val quantity: Float
)
data class OrderUnitInput(
val code: String
)
However starting the application context always yields:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQLSchema' defined in class path resource [graphql/kickstart/tools/boot/GraphQLJavaToolsAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLSchema]: Factory method 'graphQLSchema' threw exception; nested exception is graphql.kickstart.tools.SchemaError: Expected type 'OrderUnitInput' to be a GraphQLInputType, but it wasn't! Was a type only permitted for object types incorrectly used as an input type, or vice-versa?