Skip to content

Instantly share code, notes, and snippets.

@schickling
Created December 4, 2018 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schickling/cf78d1c8de54a4c23fb9efb90559fcbd to your computer and use it in GitHub Desktop.
Save schickling/cf78d1c8de54a4c23fb9efb90559fcbd to your computer and use it in GitHub Desktop.
import type { Context } from '../../';
type EditReleaseInput = {
data: {
releaseId: string,
title?: string,
},
};
export default async (
_: void,
{ data }: EditReleaseInput,
{ prisma, viewerId }: Context
) => {
const hasAccess = await prisma.organization({
projects_some: {
releases_some: {
id: data.releaseId,
},
},
users_some: {
id: viewerId,
},
}).$exists();
if (!hasAccess)
throw new Error("This release does not exist or you don't have access.");
return await prisma
.release({ id: data.releaseId })
.$upsert({
update: { title: data.title },
create: { title: data.title, id: data.releaseId },
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment