fix some bug and produce many problem to solve later
This commit is contained in:
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user