UNPKG

1.59 kBTypeScriptView Raw
1import 'reflect-metadata';
2import { BaseTypeOptions, ReturnTypeFunc } from '../interfaces';
3/**
4 * Interface defining options that can be passed to `@Subscription()` decorator.
5 */
6export type SubscriptionOptions<T = any> = BaseTypeOptions<T> & {
7 /**
8 * Name of the subscription.
9 */
10 name?: string;
11 /**
12 * Description of the subscription.
13 */
14 description?: string;
15 /**
16 * Subscription deprecation reason (if deprecated).
17 */
18 deprecationReason?: string;
19 /**
20 * Filter messages function.
21 */
22 filter?: (payload: any, variables: any, context: any) => boolean | Promise<boolean>;
23 /**
24 * Resolve messages function (to transform payload/message shape).
25 */
26 resolve?: (payload: any, args: any, context: any, info: any) => any | Promise<any>;
27};
28/**
29 * Subscription handler (method) Decorator. Routes subscriptions to this method.
30 */
31export declare function Subscription(): MethodDecorator;
32/**
33 * Subscription handler (method) Decorator. Routes subscriptions to this method.
34 */
35export declare function Subscription(name: string): MethodDecorator;
36/**
37 * Subscription handler (method) Decorator. Routes subscriptions to this method.
38 */
39export declare function Subscription(name: string, options: Pick<SubscriptionOptions, 'filter' | 'resolve'>): MethodDecorator;
40/**
41 * Subscription handler (method) Decorator. Routes subscriptions to this method.
42 */
43export declare function Subscription(typeFunc: ReturnTypeFunc, options?: SubscriptionOptions): MethodDecorator;
44//# sourceMappingURL=subscription.decorator.d.ts.map
\No newline at end of file