【发布时间】:2021-03-30 20:29:24
【问题描述】:
您好,我设法发布了数据,但我正在为订阅而苦苦挣扎,这是我的代码
Subscription,
Root,
ResolverFilterData
} from 'type-graphql';
import { DynamoDBEventStore, PubSub } from 'aws-lambda-graphql';
import { awsClient } from '../../config/database';
import { Notification, NotificationPayload } from './notification.type';
const eventStore = new DynamoDBEventStore({
dynamoDbClient: awsClient
});
const pubSub = new PubSub({ eventStore });
以及订阅:
@Subscription({
subscribe: (rootValue, args, context, info) => {
return context.pubSub.subscribe('NEW_MESSAGE')(rootValue.message);
}
})
normalSubs(@Root() { id, message }: NotificationPayload): Notification {
return { id, message, date: new Date() };
}
【问题讨论】:
标签: aws-lambda amazon-dynamodb typegraphql