Nachhilfesystem24/api/src/services/nachhilfeangebots/nachhilfeangebots.ts
KoCoder 9d72e3443b
Some checks failed
build-docker-imge / Build the docker container (push) Failing after 1m25s
Bulk-commit
2024-10-26 08:43:37 +02:00

48 lines
1.1 KiB
TypeScript

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()
},
}