import { Inject } from '@nestjs/common' ; import { Resolver , Subscription } from '@nestjs/graphql' ; import { PinoLogger } from 'nestjs-pino' ; import { PubSub } from 'graphql-subscriptions' ; import { Comment } from '../graphql/typings' ; @ Resolver ( ) export class CommentsSubscriptionResolver { constructor ( @ Inject ( 'PubSubService' ) private readonly pubSubService , private readonly logger ) { logger . setContext ( CommentsSubscriptionResolver . name ) ; } @ Subscription ( 'commentAdded' , { resolve : ( value ) => value , filter : ( payload , variables ) => payload . post === variables . post } ) commentAdded ( ) { return this . pubSubService . asyncIterator ( 'commentAdded' ) ; } }