Skip to content

Latest commit

 

History

History
96 lines (55 loc) · 3.03 KB

SubscribeOptions.md

File metadata and controls

96 lines (55 loc) · 3.03 KB

graphql-lambda-subscriptions / SubscribeOptions

Interface: SubscribeOptions<T, TSubscribeArgs>

Type parameters

Name Type
T extends PubSubEvent
TSubscribeArgs extends SubscribeArgs = SubscribeArgs

Table of contents

Properties

Properties

filter

Optional filter: SubscriptionFilter<TSubscribeArgs, T["payload"]>

An object or a function that returns an object that will be matched against the payload of a published event. If the payload's field equals the filter the subscription will receive the event. If the payload is missing the filter's field the subscription will receive the event.


onAfterSubscribe

Optional onAfterSubscribe: (...args: TSubscribeArgs) => MaybePromise<void>

Type declaration

▸ (...args): MaybePromise<void>

Gets resolver arguments to perform work after a subscription saved. This is useful for sending out initial events.

Parameters
Name Type
...args TSubscribeArgs
Returns

MaybePromise<void>


onComplete

Optional onComplete: (...args: TSubscribeArgs) => MaybePromise<void>

Type declaration

▸ (...args): MaybePromise<void>

Called at least once. Gets resolver arguments to perform work after a subscription has ended. This is useful for bookkeeping or logging. This callback will fire

If the client disconnects, sends a complete message, or the server sends a complete message via the pub/sub system. Because of the nature of aws lambda, it's possible for a client to send a "complete" message immediately disconnect and have those events execute on lambda out of order. Which why this function can be called up to twice.

Parameters
Name Type
...args TSubscribeArgs
Returns

MaybePromise<void>


onSubscribe

Optional onSubscribe: (...args: TSubscribeArgs) => MaybePromise<void | GraphQLError[]>

Type declaration

▸ (...args): MaybePromise<void | GraphQLError[]>

Gets resolver arguments to perform work before a subscription is allowed. This is useful for checking arguments or validating permissions. Return an array of GraphqlErrors if you don't want the subscription to subscribe.

Parameters
Name Type
...args TSubscribeArgs
Returns

MaybePromise<void | GraphQLError[]>