add mutation update user info

This commit is contained in:
2024-10-11 18:01:40 +07:00
parent c3678cf6c5
commit a454a91e0a

View File

@@ -69,11 +69,29 @@ export class UserSchema extends PothosSchema {
},
}),
}));
}
// Mutation section
@Pothos()
createUser() {
return 'createUser';
// Mutation section
this.builder.mutationFields((t) => ({
updateUser: t.prismaField({
type: this.user(),
args: {
input: t.arg({
type: this.builder.generator.getUpdateInput('User'),
required: true,
}),
where: t.arg({
type: this.builder.generator.getWhereUnique('User'),
required: true,
}),
},
resolve: async (query, root, args, ctx, info) => {
return await this.prisma.user.update({
...query,
where: args.where,
data: args.input,
});
},
}),
}));
}
}