【发布时间】:2020-09-14 16:02:45
【问题描述】:
在 prisma 1 中,我使用片段来获取嵌套字段。
例如:
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;
},
};
但似乎在 prisma2 中不受支持。因为通过在操场上运行它,
mutation CREATEPOST {
createPost(
title: "How to sleep?"
body: "Eat, sleep, repaet"
published: true
) {
title
body
published
author {
id
}
}
}
我明白了,
"prisma.post.create(...).$fragment is not a function",
【问题讨论】:
标签: javascript node.js graphql prisma prisma-graphql