【发布时间】:2020-05-06 14:18:58
【问题描述】:
我正在尝试创建一个接收如下输入类型的 Mutation:
input Cart {
items: [CartItem!]!
client: String!
}
input CartItem {
productId: Int!
qty: Int!
}
我的变异是这样的:
type Mutation {
createOrder(cart: Cart!): Order!
}
但是当我尝试运行我的应用程序时,出现以下异常:
Caused by: com.coxautodev.graphql.tools.SchemaError: Expected type 'CartItem' to be a GraphQLOutputType, but it wasn't! Was a type only permitted for object types incorrectly used as an input type, or vice-versa?
发生了什么事?
【问题讨论】:
-
您是否在架构中的其他任何地方使用 CartItem,例如作为 Order 的一部分?
-
不,在这种情况下只是作为输入类型
-
你确定你的 Cart 和 CartItem java 类有公共的 getter 吗?
标签: spring-boot graphql graphql-java