chore: refactor pub/sub iterator usage across schema files
- Updated pub/sub iterator methods from `asyncIterableIterator` to `asyncIterator` in multiple schema files for improved compatibility with the latest GraphQL subscriptions. - Refactored subscription logic in CollaborationSession, Document, Message, User, and other schema files to enhance readability and maintainability. - Adjusted imports in GraphQL builder to utilize RedisPubSub for better performance in subscription handling.
This commit is contained in:
@@ -197,10 +197,9 @@ export class MessageSchema extends PothosSchema {
|
||||
if (!ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
const {
|
||||
websocket: { pubSub },
|
||||
} = ctx
|
||||
return pubSub.asyncIterableIterator([`${PubSubEvent.MESSAGE_SENT}.${args.chatRoomId}`])
|
||||
return ctx.websocket.pubSub.asyncIterator([
|
||||
`${PubSubEvent.MESSAGE_SENT}.${args.chatRoomId}`,
|
||||
]) as unknown as AsyncIterable<Message>
|
||||
},
|
||||
resolve: (payload: Message) => payload,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user