java不能在GraphQL中有嵌套字段的输入类型。错误:类型应为GraphQLInputType,但不是
我有一个查询,我想输入购物车对象的嵌套结构。我还在Kotlin中定义了与数据类完全相同的结构
这是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!
}
这是相应的类别:
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
)
但是,启动应用程序上下文始终会产生:
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?
共 (0) 个答案