I trying to add mutation in graphql-yoga but every time I try to mutate the I get error saying
Post validation failed: title: Path
titleis required.",
I have no idea why.
Here is my code
resolver
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
}
}
}
schema
input postInput{
title: String!
description: String!
content: String!
}
type Mutation {
createPost(input: postInput): Post!
}
This works fine if I remove the input type and directly do like this
type Mutation {
createPost(title: String!,description: String!,content: String!): Post!
}
log result
{ input:
[Object: null prototype] {
title: 'with input',
description: 'this is de',
content: 'this is conte' } }
Here Why am I getting [Object: null prototype]?