import type { QueryResolvers, MutationResolvers, NachhilfeangebotRelationResolvers, } from 'types/graphql' import { db } from 'src/lib/db' export const nachhilfeangebots: QueryResolvers['nachhilfeangebots'] = () => { return db.nachhilfeangebot.findMany() } export const nachhilfeangebot: QueryResolvers['nachhilfeangebot'] = ({ id, }) => { return db.nachhilfeangebot.findUnique({ where: { id }, }) } export const createNachhilfeangebot: MutationResolvers['createNachhilfeangebot'] = ({ input }) => { return db.nachhilfeangebot.create({ data: input, }) } export const updateNachhilfeangebot: MutationResolvers['updateNachhilfeangebot'] = ({ id, input }) => { return db.nachhilfeangebot.update({ data: input, where: { id }, }) } export const deleteNachhilfeangebot: MutationResolvers['deleteNachhilfeangebot'] = ({ id }) => { return db.nachhilfeangebot.delete({ where: { id }, }) } export const Nachhilfeangebot: NachhilfeangebotRelationResolvers = { user: (_obj, { root }) => { return db.nachhilfeangebot.findUnique({ where: { id: root?.id } }).user() }, }