【发布时间】:2019-12-27 10:41:18
【问题描述】:
我试图在 graphql-yoga 中添加变异,但每次我尝试变异时都会出现错误提示
后验证失败:标题:路径
title是必需的。",
我不知道为什么。
这是我的代码
解析器
Mutation: {
createPost: async(root, args, ctx) => {
console.log(args)
try {
const post = new Post({
title: args.title,
description: args.description,
content: args.content
});
const result = await post.save();
console.log(result);
return result
}catch(err) {
throw err
}
}
}
架构
input postInput{
title: String!
description: String!
content: String!
}
type Mutation {
createPost(input: postInput): Post!
}
如果我删除输入类型并直接这样做,这很好用
type Mutation {
createPost(title: String!,description: String!,content: String!): Post!
}
日志结果
{ input:
[Object: null prototype] {
title: 'with input',
description: 'this is de',
content: 'this is conte' } }
这里为什么我收到[Object: null prototype]?
【问题讨论】:
标签: graphql