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:
2024-12-08 21:54:23 +07:00
parent 8b36e7d05a
commit ba32ee8dc1
6 changed files with 19 additions and 21 deletions

View File

@@ -324,7 +324,9 @@ export class CollaborationSessionSchema extends PothosSchema {
if (!collaborationSession) {
throw new Error('Collaboration session not found')
}
return ctx.websocket.pubSub.asyncIterableIterator(`collaborationSessionUpdated:${collaborationSession.id}`)
return ctx.websocket.pubSub.asyncIterator([
`collaborationSessionUpdated:${collaborationSession.id}`,
]) as unknown as AsyncIterable<CollaborationSession>
},
resolve: async (payload: CollaborationSession) => payload,
}),