chore: update configuration and improve schema imports

- Updated biome.json to include "graphql.d.ts" in the ignored files list.
- Updated subproject commit reference in epess-database to the latest version.
- Removed unused script from package.json and streamlined module file extensions in tsconfig.json.
- Consolidated exclude patterns in tsconfig.build.json for clarity.
- Refactored imports across multiple schema files for consistency and improved readability.
- Enhanced various schema files by ensuring proper import order and removing redundant code.
- Improved error handling and data integrity checks in several service and schema files.
This commit is contained in:
2024-12-08 20:49:52 +07:00
parent 9e6d62e4be
commit 10e20092ab
82 changed files with 1697 additions and 2259 deletions

View File

@@ -1,20 +1,10 @@
import { Inject, Injectable, Logger } from '@nestjs/common'
import {
Pothos,
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
import { ChatRoomType, Message, MessageContextType, MessageType } from '@prisma/client'
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
import { Builder, SchemaContext } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service'
import {
ChatRoomType,
Message,
MessageContextType,
MessageType,
} from '@prisma/client'
import { DateTimeUtils } from '../common/utils/datetime.utils'
import { PubSubEvent } from '../common/pubsub/pubsub-event'
import { DateTimeUtils } from '../common/utils/datetime.utils'
@Injectable()
export class MessageSchema extends PothosSchema {
@@ -85,8 +75,7 @@ export class MessageSchema extends PothosSchema {
}),
messages: t.prismaField({
type: [this.message()],
description:
'Retrieve a list of messages with optional filtering, ordering, and pagination.',
description: 'Retrieve a list of messages with optional filtering, ordering, and pagination.',
args: this.builder.generator.findManyArgs('Message'),
resolve: async (query, _root, args) => {
return await this.prisma.message.findMany({
@@ -184,16 +173,10 @@ export class MessageSchema extends PothosSchema {
})
return message
})
ctx.http.pubSub.publish(
`${PubSubEvent.MESSAGE_SENT}.${message.chatRoomId}`,
message,
)
ctx.http.pubSub.publish(`${PubSubEvent.MESSAGE_SENT}.${message.chatRoomId}`, message)
// publish to new message subscribers
userIds.forEach((userId: string) => {
ctx.http.pubSub.publish(
`${PubSubEvent.NEW_MESSAGE}.${userId}`,
message,
)
ctx.http.pubSub.publish(`${PubSubEvent.NEW_MESSAGE}.${userId}`, message)
})
return message
},
@@ -215,9 +198,7 @@ export class MessageSchema extends PothosSchema {
const {
websocket: { pubSub },
} = ctx
return pubSub.asyncIterableIterator([
`${PubSubEvent.MESSAGE_SENT}.${args.chatRoomId}`,
])
return pubSub.asyncIterableIterator([`${PubSubEvent.MESSAGE_SENT}.${args.chatRoomId}`])
},
resolve: (payload: Message) => payload,
}),