Skip to content

Function: InjectPubSub()

ts
function InjectPubSub(): ParameterDecorator;

Defined in: packages/graphql-pubsub/src/decorators/inject-pubsub.decorator.ts:23

Parameter decorator that injects the RedisPubSub instance registered under the GRAPHQL_PUBSUB token.

Requires GraphQLPubSubModule (or its global variant) to be imported in the application module.

Returns

ParameterDecorator

Example

typescript
@Injectable()
class SubscriptionsService {
  constructor(@InjectPubSub() private readonly pubsub: RedisPubSub) {}

  publish(event: string, payload: unknown): Promise<void> {
    return this.pubsub.publish(event, payload);
  }
}

Released under the MIT License.