I have this mutation that returns as expected: id, url and description.
post(parent, args, context, info) {
const userId = getUserId(context);
const user = await context.User.findOne({ _id: userId });
return context.Link.create(
{
url: args.url,
description: args.description,
postedBy: userId
},
}
The problem is when I add this function that successfully update Refs to children
async post(parent,args,context,info){
const userId = getUserId(context);
const user = await context.User.findOne({ _id: userId });
return context.Link.create(
{
url: args.url,
description: args.description,
postedBy: userId
},
**function(error, createdLink) {
user.links.push(createdLink._id);
user.save(createdLink);
}**
);
}
Everything works perfect in mongoose and mongo, but graphQL returns null:
{
"data": {
"post": null
}
}
What i am doing wrong?