import { Prisma } from '@prisma/client' ; import { Resolver , Query , Arg , Int , Mutation } from 'type-graphql' ; import { CreateVenueInputs , UpdateVenueInputs } from './inputs' ; import { Venue } from 'src/graphql-types' ; import { prisma } from 'src/prisma' ; @ Resolver ( ) export class VenueResolver { @ Query ( ( ) => [ Venue ] ) venues ( ) { return prisma . venues . findMany ( ) ; } @ Query ( ( ) => Venue , { nullable : true } ) venue ( @ Arg ( 'id' , ( ) => Int ) id ) { return prisma . venues . findUnique ( { where : { id } } ) ; } @ Mutation ( ( ) => Venue ) async createVenue ( @ Arg ( 'data' ) data ) { const venueData = data ; return prisma . venues . create ( { data : venueData } ) ; } @ Mutation ( ( ) => Venue ) updateVenue ( @ Arg ( 'id' , ( ) => Int ) id , @ Arg ( 'data' ) data ) { const venueData = data ; return prisma . venues . update ( { where : { id } , data : venueData } ) ; } @ Mutation ( ( ) => Boolean ) async deleteVenue ( @ Arg ( 'id' , ( ) => Int ) id ) { await prisma . venues . delete ( { where : { id } } ) ; return true ; } }