chore: remove Milestone module and update related schemas

- Deleted the MilestoneModule and its associated schema to streamline the codebase.
- Updated QuizSchema to replace scheduleId with serviceId, enhancing the relationship structure.
- Removed references to Milestone in ServiceSchema, improving clarity and focus on relevant entities.
- Updated Prisma types to reflect the removal of Milestone, ensuring data integrity across the application.
This commit is contained in:
2024-12-07 15:33:28 +07:00
parent 4af2e848b8
commit 429c6f9073
7 changed files with 16 additions and 114 deletions

View File

@@ -14,7 +14,6 @@ import { GraphQLModule } from '@nestjs/graphql'
import { GraphqlService } from './graphql.service' import { GraphqlService } from './graphql.service'
import { ManagedServiceModule } from '../ManagedService/managedservice.module' import { ManagedServiceModule } from '../ManagedService/managedservice.module'
import { MessageModule } from '../Message/message.module' import { MessageModule } from '../Message/message.module'
import { MilestoneModule } from '../Milestone/milestone.module'
import { OrderModule } from '../Order/order.module' import { OrderModule } from '../Order/order.module'
import { PaymentModule } from '../Payment/payment.module' import { PaymentModule } from '../Payment/payment.module'
import { PothosApolloDriver } from '@smatch-corp/nestjs-pothos-apollo-driver' import { PothosApolloDriver } from '@smatch-corp/nestjs-pothos-apollo-driver'
@@ -72,7 +71,6 @@ import { PubSubService } from '../PubSub/pubsub.service'
ServiceAndCategoryModule, ServiceAndCategoryModule,
CategoryModule, CategoryModule,
ServiceFeedbackModule, ServiceFeedbackModule,
MilestoneModule,
ScheduleModule, ScheduleModule,
MessageModule, MessageModule,
CollaborationSessionModule, CollaborationSessionModule,

View File

@@ -1,8 +0,0 @@
import { Module } from '@nestjs/common'
import { MilestoneSchema } from './milestone.schema'
@Module({
providers: [MilestoneSchema],
exports: [MilestoneSchema],
})
export class MilestoneModule {}

View File

@@ -1,85 +0,0 @@
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 '../Prisma/prisma.service'
@Injectable()
export class MilestoneSchema extends PothosSchema {
constructor(
@Inject(SchemaBuilderToken) private readonly builder: Builder,
private readonly prisma: PrismaService,
) {
super()
}
@PothosRef()
milestone() {
return this.builder.prismaObject('Milestone', {
description: 'A milestone in the system.',
fields: (t) => ({
id: t.exposeID('id', {
description: 'The ID of the milestone.',
}),
name: t.exposeString('name', {
description: 'The name of the milestone.',
}),
milestoneOrder: t.exposeInt('milestoneOrder', {
description: 'The order of the milestone.',
}),
description: t.exposeString('description', {
description: 'The description of the milestone.',
}),
serviceId: t.exposeID('serviceId', {
description: 'The ID of the service the milestone belongs to.',
}),
service: t.relation('service'),
createdAt: t.expose('createdAt', {
type: 'DateTime',
description: 'The date and time the milestone was created.',
}),
updatedAt: t.expose('updatedAt', {
type: 'DateTime',
description: 'The date and time the milestone was last updated.',
}),
}),
})
}
@Pothos()
init(): void {
this.builder.queryFields((t) => ({
milestones: t.prismaField({
type: [this.milestone()],
args: this.builder.generator.findManyArgs('Milestone'),
description:
'Retrieve a list of milestones with optional filtering, ordering, and pagination.',
resolve: async (query, _root, args, _ctx, _info) => {
return await this.prisma.milestone.findMany({
...query,
skip: args.skip ?? undefined,
take: args.take ?? undefined,
cursor: args.cursor ?? undefined,
orderBy: args.orderBy ?? undefined,
where: args.filter ?? undefined,
})
},
}),
milestone: t.prismaField({
type: this.milestone(),
args: this.builder.generator.findUniqueArgs('Milestone'),
description: 'Retrieve a single milestone by its unique identifier.',
resolve: async (query, _root, args, _ctx, _info) => {
return await this.prisma.milestone.findUnique({
...query,
where: args.where,
})
},
}),
}))
}
}

View File

@@ -20,8 +20,8 @@ export class QuizSchema extends PothosSchema {
return this.builder.prismaObject('Quiz', { return this.builder.prismaObject('Quiz', {
fields: (t) => ({ fields: (t) => ({
id: t.exposeID('id'), id: t.exposeID('id'),
scheduleId: t.exposeID('scheduleId'), serviceId: t.exposeID('serviceId'),
schedule: t.relation('schedule'), service: t.relation('service'),
quizTitle: t.exposeString('quizTitle'), quizTitle: t.exposeString('quizTitle'),
quizSynopsis: t.exposeString('quizSynopsis'), quizSynopsis: t.exposeString('quizSynopsis'),
progressBarColor: t.exposeString('progressBarColor'), progressBarColor: t.exposeString('progressBarColor'),

View File

@@ -102,9 +102,6 @@ export class ServiceSchema extends PothosSchema {
workshop: t.relation('workshop', { workshop: t.relation('workshop', {
description: 'The workshop for the service.', description: 'The workshop for the service.',
}), }),
milestone: t.relation('milestone', {
description: 'The milestone for the service.',
}),
serviceAndCategory: t.relation('serviceAndCategory', { serviceAndCategory: t.relation('serviceAndCategory', {
description: 'The service and category for the service.', description: 'The service and category for the service.',
}), }),

File diff suppressed because one or more lines are too long