191
rated 0 times
[
192]
[
1]
/ answers: 1 / hits: 11009
/ 4 Years ago, wed, may 27, 2020, 12:00:00
In prisma 1 I have used fragment to fetch the nested fields.
For example:
const mutations = {
async createPost(_, args, ctx) {
const user = await loginChecker(ctx);
const post = await prisma.post
.create({
data: {
author: {
connect: {
id: user.id,
},
},
title: args.title,
body: args.body,
published: args.published,
},
})
.$fragment(fragment);
return post;
},
};
but seems like in prisma2 it is not supported. because by running this on playground,
mutation CREATEPOST {
createPost(
title: How to sleep?
body: Eat, sleep, repaet
published: true
) {
title
body
published
author {
id
}
}
}
I am getting,
prisma.post.create(...).$fragment is not a function,
More From » node.js