我具有以下数据库模型
type GlobalUser {
email: String
createdAt: DateTime!
updatedAt: DateTime!
}
type Client {
global_user: GlobalUser!
createdAt: DateTime!
updatedAt: DateTime!
}
每次创建GlobalUser时,我都想在客户端表中创建一个客户端。 如果我选择使用Apollo从应用程序的Angular客户端执行此操作,则可能是这种方法,在该方法中,我使用Promises将一个突变称为另一个突变。
document = gql`
mutation createGlobalUser(
$email: String!,$password: String!
) {
createGlobalUser(
email: $email,password: $password,) {
email
}
}
`;
createGlobalUserService.mutate({
email: email
}).toPromise().then((res) => {
createclientService.mutate({
global_user: res.data.id
}).catch(err => {
console.log(err);
});
我找不到从服务器端Prisma解析器执行此操作的方法
const Mutation = {
async createGlobalUser(root,args,context) {
const user = await context.prisma.createGlobalUser({
...args
});
return {
id
email
}
}
有没有一种方法可以使用Angular中的Apollo从客户端组合并执行多个Mutations?还是在服务器端更好?