【发布时间】:2017-11-13 14:08:40
【问题描述】:
我的架构文件是
type Mutation {
createCustomer(name: String!, email: String!, product: [Product]): Customer
}
input Product {
id: ID!
name: String!
price: Int
}
interface Person {
id: ID!
name: String!
email: String!
}
type Customer implements Person {
id: ID!
name: String!
email: String!
product: [Product]
}
我想在此处插入以产品列表作为输入的客户详细信息。我的查询是
mutation {
createCustomer(
name: "kitte",
email: "kitte@gmail.com",
product: [
{
name: "soap",
price: 435,
}
]
)
{
id
name
email
product{name}
}
}
但是我遇到了异常
{
"data": null,
"errors": [
{
"validationErrorType": "WrongType",
"message": "Validation error of type WrongType: argument value ArrayValue{values=[ObjectValue{objectFields=[ObjectField{name='name', value=StringValue{value='dars76788hi'}}, ObjectField{name='price', value=IntValue{value=123}}]}, ObjectValue{objectFields=[ObjectField{name='name', value=StringValue{value='darr'}}, ObjectField{name='price', value=IntValue{value=145}}]}]} has wrong type",
"locations": [
{
"line": 5,
"column": 5
}
],
"errorType": "ValidationError"
}
]
}
我不明白错误是什么。以及如何将列表传递给突变。我引用了一些示例,但无法将产品作为列表插入。
【问题讨论】:
-
您是否尝试过在您的变异中获取一些产品字段,例如
mutation { createCustomer(...) { id, name, email, product {name} } }? -
它解决了这个错误。但出现新错误
标签: spring-boot graphql