我可以在Apollo Sandbox中创建一个项目-下面是来自Apollo Sandbox的项目副本
{"data": {"createProject": {"_id": "65952c08576a8d317dc4df47", "description": "front end", "name": "new react", status": [{"code": "a", "launch": "c", "content": "b", "planning": "d","qa": "f", "start": "g", "ux": "h" }]}}
字符串
然而,我在客户端添加了如下突变
mutation createProject($name: String! $description: String! $status: [StatusInput]!) { createProject(name: $name, description: $description, status: $status) { _id name description status {start planning ux content code qa launch }}}
型
下面是提交处理程序的useQuery代码
const handleSubmit = async (event) => {
event.preventDefault();
try {
const mutationRes = await createProject({
variables: {
name: formState.name,
description: formState.description,
status: formState.status,
},
});
console.log(mutationRes);
} catch (err) {
console.log(err);
}
};
型
我能够看到名称,描述和状态的网络选项卡中的响应,但我得到400状态代码,说明GraphQLError: Expected type "StatusInput" to be an object."
服务器端类型定义:输入
input StatusInput { start: String! planning: String! ux: String! content: String! code: String! qa: String! launch: String! project: ID! }
型
和变异
createProject( name: String! description: String! status: [StatusInput]! ): Project
型
1条答案
按热度按时间chhkpiq41#
我改变了模式
字符串
类型定义
型
}
型
与枚举我能够分配项目状态,并解决了问题-任何更多的信息,请随时与我联系