- Modified file output paths in LiveKitRoomService to utilize the BUCKET_NAME environment variable for dynamic S3 storage. - Introduced a new `feedbacked` field in ServiceSchema to track whether a user has provided feedback for a service, enhancing user interaction capabilities. - Cleaned up the ServiceFeedback schema by refining the resolve function for better clarity and consistency.
75 lines
2.5 KiB
TypeScript
75 lines
2.5 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 '../Prisma/prisma.service'
|
|
|
|
@Injectable()
|
|
export class ServiceFeedbackSchema extends PothosSchema {
|
|
constructor(
|
|
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
|
private readonly prisma: PrismaService,
|
|
) {
|
|
super()
|
|
}
|
|
|
|
@PothosRef()
|
|
serviceFeedback() {
|
|
return this.builder.prismaObject('ServiceFeedback', {
|
|
description: 'A feedback for a service.',
|
|
fields: (t) => ({
|
|
id: t.exposeID('id', {
|
|
description: 'The ID of the service feedback.',
|
|
}),
|
|
userId: t.exposeID('userId', {
|
|
description: 'The ID of the user who provided the feedback.',
|
|
}),
|
|
serviceId: t.exposeID('serviceId', {
|
|
description: 'The ID of the service that was provided.',
|
|
}),
|
|
rating: t.exposeFloat('rating', {
|
|
description: 'The rating of the service.',
|
|
}),
|
|
comments: t.exposeString('comments', {
|
|
description: 'The comments of the service feedback.',
|
|
}),
|
|
createdAt: t.expose('createdAt', {
|
|
type: 'DateTime',
|
|
nullable: true,
|
|
description: 'The date and time the service feedback was created.',
|
|
}),
|
|
updatedAt: t.expose('updatedAt', {
|
|
type: 'DateTime',
|
|
nullable: true,
|
|
description: 'The date and time the service feedback was updated.',
|
|
}),
|
|
user: t.relation('user', {
|
|
description: 'The user who provided the feedback.',
|
|
}),
|
|
service: t.relation('service', {
|
|
description: 'The service that was provided.',
|
|
}),
|
|
}),
|
|
})
|
|
}
|
|
|
|
@Pothos()
|
|
init(): void {
|
|
this.builder.queryFields((t) => ({
|
|
serviceFeedbacks: t.prismaField({
|
|
type: [this.serviceFeedback()],
|
|
args: this.builder.generator.findManyArgs('ServiceFeedback'),
|
|
description: 'Retrieve a list of service feedbacks with optional filtering, ordering, and pagination.',
|
|
resolve: async (query, _root, args, _ctx, _info) => {
|
|
return await this.prisma.serviceFeedback.findMany({
|
|
...query,
|
|
skip: args.skip ?? undefined,
|
|
take: args.take ?? undefined,
|
|
orderBy: args.orderBy ?? undefined,
|
|
where: args.filter ?? undefined,
|
|
})
|
|
},
|
|
}),
|
|
}))
|
|
}
|
|
}
|