import type { QueryResolvers, UserRelationResolvers } from 'types/graphql'

import { db } from 'src/lib/db'

export const users: QueryResolvers['users'] = () => {
  return db.user.findMany()
}

export const user: QueryResolvers['user'] = ({ id }) => {
  return db.user.findUnique({
    where: { id },
  })
}

export const User: UserRelationResolvers = {
  identites: (_obj, { root }) => {
    return db.user.findUnique({ where: { id: root?.id } }).identites()
  },
  Nachhilfeangebot: (_obj, { root }) => {
    return db.user.findUnique({ where: { id: root?.id } }).Nachhilfeangebot()
  },
}
