Files
epess-web-backend/src/workshop/workshop.schema.ts
2024-10-07 20:46:20 +07:00

46 lines
1.2 KiB
TypeScript

import { Inject, Injectable } from '@nestjs/common';
import {
Pothos,
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos';
import { Builder } from '../graphql/graphql.builder';
import { PrismaService } from 'src/prisma/prisma.service';
@Injectable()
export class WorkshopSchema extends PothosSchema {
constructor(
@Inject(SchemaBuilderToken) private readonly builder: Builder,
private readonly prisma: PrismaService,
) {
super();
}
@PothosRef()
workshop() {
return this.builder.prismaObject('Workshop', {
fields: (t) => ({
id: t.exposeID('id'),
title: t.exposeString('title'),
description: t.exposeString('description'),
staffId: t.exposeID('staffId'),
serviceId: t.exposeID('serviceId'),
date: t.expose('date', {
type: 'Date',
}),
createdAt: t.expose('createdAt', {
type: 'Date',
}),
updatedAt: t.expose('updatedAt', {
type: 'Date',
}),
service: t.relation('service'),
workshopOrganization: t.relation('workshopOrganization'),
workshopSubscription: t.relation('workshopSubscription'),
staff: t.relation('staff'),
}),
});
}
}