Skip to content

Instantly share code, notes, and snippets.

@gc-codesnippets
Created December 4, 2018 09:35
Show Gist options
  • Save gc-codesnippets/dbb62dbeb8935f7e8d5ea7fab24b6582 to your computer and use it in GitHub Desktop.
Save gc-codesnippets/dbb62dbeb8935f7e8d5ea7fab24b6582 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 }).$update({ title: data.title })
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment