chore: update package dependencies and improve pub/sub iterator usage
- Updated various package dependencies in package-lock.json and package.json for enhanced stability and performance. - Changed pub/sub iterator methods from `asyncIterator` to `asyncIterableIterator` in multiple schema files for better compatibility with the latest GraphQL subscriptions. - Added `moduleResolution` option in tsconfig.json to support Node.js-style module resolution.
This commit is contained in:
@@ -283,9 +283,9 @@ export class CollaborationSessionSchema extends PothosSchema {
|
||||
},
|
||||
})
|
||||
if (!collaborationSession) throw new Error('Collaboration session not found')
|
||||
return ctx.websocket.pubSub.asyncIterator(
|
||||
return ctx.websocket.pubSub.asyncIterableIterator(
|
||||
`collaborationSessionUpdated:${collaborationSession.id}`,
|
||||
) as unknown as AsyncIterable<CollaborationSession>
|
||||
)
|
||||
},
|
||||
resolve: async (payload: CollaborationSession) => payload,
|
||||
}),
|
||||
|
||||
@@ -406,7 +406,7 @@ export class DocumentSchema extends PothosSchema {
|
||||
)
|
||||
throw new Error('User is not owner or collaborator of document')
|
||||
}
|
||||
return pubSub.asyncIterator([
|
||||
return pubSub.asyncIterableIterator([
|
||||
`${DocumentEvent.CHANGED}.${documentId}`,
|
||||
`${DocumentEvent.DELETED}.${documentId}`,
|
||||
`${DocumentEvent.SAVED}.${documentId}`,
|
||||
|
||||
@@ -101,8 +101,8 @@ export class Builder extends SchemaBuilder<SchemaBuilderOption> {
|
||||
debounceDelay: 1000,
|
||||
...subscribeOptionsFromIterator((name, context) => {
|
||||
return context.isSubscription
|
||||
? context.websocket.pubSub.asyncIterator(name)
|
||||
: context.http.pubSub.asyncIterator(name)
|
||||
? context.websocket.pubSub.asyncIterableIterator(name)
|
||||
: context.http.pubSub.asyncIterableIterator(name)
|
||||
}),
|
||||
},
|
||||
zod: {
|
||||
|
||||
@@ -215,9 +215,9 @@ export class MessageSchema extends PothosSchema {
|
||||
const {
|
||||
websocket: { pubSub },
|
||||
} = ctx
|
||||
return pubSub.asyncIterator([
|
||||
return pubSub.asyncIterableIterator([
|
||||
`${PubSubEvent.MESSAGE_SENT}.${args.chatRoomId}`,
|
||||
]) as unknown as AsyncIterable<Message>
|
||||
])
|
||||
},
|
||||
resolve: (payload: Message) => payload,
|
||||
}),
|
||||
|
||||
@@ -544,10 +544,10 @@ export class UserSchema extends PothosSchema {
|
||||
const {
|
||||
websocket: { pubSub },
|
||||
} = ctx
|
||||
return pubSub.asyncIterator([
|
||||
return pubSub.asyncIterableIterator([
|
||||
`${PubSubEvent.NEW_MESSAGE}.${ctx.websocket.me?.id}`,
|
||||
`${PubSubEvent.NOTIFICATION}.${ctx.websocket.me?.id}`,
|
||||
]) as unknown as AsyncIterable<Message>
|
||||
])
|
||||
},
|
||||
resolve: async (payload: Message) => payload,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user