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