import { Prisma } from '@prisma/client' ; import { Resolver , Query , Arg , Int , Mutation } from 'type-graphql' ; import { CreateSponsorInputs , UpdateSponsorInputs } from './input' ; import { Sponsor } from 'src/graphql-types/Sponsor' ; import { prisma } from 'src/prisma' ; @ Resolver ( ) export class SponsorResolver { @ Query ( ( ) => [ Sponsor ] ) sponsors ( ) { return prisma . sponsors . findMany ( ) ; } @ Query ( ( ) => Sponsor , { nullable : true } ) sponsor ( @ Arg ( 'id' , ( ) => Int ) id ) { return prisma . sponsors . findUnique ( { where : { id } } ) ; } @ Mutation ( ( ) => Sponsor ) createSponsor ( @ Arg ( 'data' ) data ) { const sponsorData = data ; return prisma . sponsors . create ( { data : sponsorData } ) ; } @ Mutation ( ( ) => Sponsor ) updateSponsor ( @ Arg ( 'id' , ( ) => Int ) id , @ Arg ( 'data' ) data ) { return prisma . sponsors . update ( { where : { id } , data } ) ; } }