Created
December 4, 2018 09:35
-
-
Save gc-codesnippets/dbb62dbeb8935f7e8d5ea7fab24b6582 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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