fix some bug and produce many problem to solve later

This commit is contained in:
2024-11-02 16:27:28 +07:00
parent e86d979ddb
commit 1a5577f8e6
15 changed files with 751 additions and 509 deletions

View File

@@ -118,22 +118,17 @@ export class MessageSchema extends PothosSchema {
}),
}))
// subscriptions
/* The code snippet `subscriptions` is currently commented out in the provided TypeScript class. It
appears to be a placeholder or a section where subscription-related logic or fields could be
defined. In GraphQL, subscriptions are used to listen for real-time events or changes in data
and receive updates when those events occur. */
this.builder.subscriptionFields((t) => ({
messageSent: t.field({
subscribe: (_, __, ctx) => {
description: 'Subscribe to messages sent by users.',
args: {},
subscribe: async (_, __, ctx) => {
if (!ctx.isSubscription) {
throw new Error('Not allowed')
}
return {
[Symbol.asyncIterator]: () =>
ctx.websocket.pubSub.asyncIterator('MESSAGE_SENT'),
}
return (await ctx.websocket.pubSub.asyncIterator(
'MESSAGE_SENT',
)) as unknown as AsyncIterable<unknown>
},
type: this.message(), // Add the type property
resolve: (payload) =>