fix: upsert dashboards

This commit is contained in:
Vyacheslav Matyukhin 2022-04-21 00:28:14 +04:00
parent f4bb0d19eb
commit 5f56ebf880
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C

View File

@ -70,8 +70,12 @@ builder.mutationField("createDashboard", (t) =>
},
resolve: async (parent, args) => {
const id = hash(JSON.stringify(args.input.ids));
const dashboard = await prisma.dashboard.create({
data: {
const dashboard = await prisma.dashboard.upsert({
where: {
id,
},
update: {},
create: {
id,
title: args.input.title,
description: args.input.description || "",