Invoking PubSub on @AfterInsert() #1132
-
Hello everyone, I was wondering if it is possible to emit a pubsub event from an @AfterInsert() Simple example: @Entity()
@ObjectType()
export class User extends BasicEntity {
@Field(() => String)
@Column({ comment: 'User First Name', nullable: false })
firstName!: string;
@AfterInsert()
async publishEvent(@PubSub() pubsub: PubSubEngine) {
await pubsub.publish('NEW_USER', this);
}
} This currently does not work and I am wondering if it is possible some other way! Thanks, |
Beta Was this translation helpful? Give feedback.
Answered by
MichalLytek
Dec 1, 2021
Replies: 1 comment 4 replies
-
Use |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
PubSub
fromgraphql-subscriptions
directly:export const pubSub = new PubSub();
Remember to register the custom pubsub - search in docs.