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:
@@ -447,9 +447,6 @@ export class DocumentSchema extends PothosSchema {
|
||||
if (!ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
const {
|
||||
websocket: { pubSub },
|
||||
} = ctx
|
||||
const documentId = args.documentId
|
||||
// check user permission
|
||||
const document = await this.prisma.document.findUnique({
|
||||
@@ -469,7 +466,7 @@ export class DocumentSchema extends PothosSchema {
|
||||
throw new Error('User is not owner or collaborator of document')
|
||||
}
|
||||
}
|
||||
return pubSub.asyncIterableIterator([
|
||||
return ctx.websocket.pubSub.asyncIterator([
|
||||
`${DocumentEvent.CHANGED}.${documentId}`,
|
||||
`${DocumentEvent.DELETED}.${documentId}`,
|
||||
`${DocumentEvent.SAVED}.${documentId}`,
|
||||
|
||||
Reference in New Issue
Block a user