Skip to content

Latest commit

 

History

History
152 lines (96 loc) · 4.43 KB

README.md

File metadata and controls

152 lines (96 loc) · 4.43 KB

graphql-lambda-subscriptions

graphql-lambda-subscriptions

Table of contents

Interfaces

Type Aliases

Functions

Type Aliases

LoggerFunction

Ƭ LoggerFunction: (message: string, obj: Record<string, any>) => void

Type declaration

▸ (message, obj): void

Log operational events with a logger of your choice. It will get a message and usually object with relevant data

Parameters
Name Type
message string
obj Record<string, any>
Returns

void


MaybePromise

Ƭ MaybePromise<T>: T | Promise<T>

Type parameters

Name
T

SubscribeArgs

Ƭ SubscribeArgs<TRoot, TArgs, TContext>: [root: TRoot, args: TArgs, context: TContext, info: GraphQLResolveInfo]

Type parameters

Name Type
TRoot unknown
TArgs Record<string, any>
TContext unknown

SubscriptionFilter

Ƭ SubscriptionFilter<TSubscribeArgs, TReturn>: Partial<TReturn> | void | (...args: TSubscribeArgs) => MaybePromise<Partial<TReturn> | void>

Type parameters

Name Type
TSubscribeArgs extends SubscribeArgs = SubscribeArgs
TReturn extends Record<string, any> = Record<string, any>

WebSocketResponse

Ƭ WebSocketResponse: Object

Type declaration

Name Type
body string
headers? Record<string, string>
statusCode number

Functions

makeServer

makeServer(opts): SubscriptionServer

Parameters

Name Type
opts ServerArgs

Returns

SubscriptionServer


subscribe

subscribe<T, TRoot, TArgs, TContext>(topic, options?): SubscribePseudoIterable<T, SubscribeArgs<TRoot, TArgs, TContext>>

Creates subscribe handler for use in your graphql schema.

subscribe is the most important method in the library. It is the primary difference between graphql-ws and graphql-lambda-subscriptions. It returns a SubscribePseudoIterable that pretends to be an async iterator that you put on the subscribe resolver for your Subscription. In reality it includes a few properties that we use to subscribe to events and fire lifecycle functions. See SubscribeOptions for information about the callbacks.

Type parameters

Name Type
T extends PubSubEvent
TRoot extends unknown = any
TArgs extends Record<string, any> = any
TContext extends unknown = any

Parameters

Name Type Description
topic T["topic"] Subscriptions are made to a string topic and can be filtered based upon the topics payload.
options SubscribeOptions<T, SubscribeArgs<TRoot, TArgs, TContext>> Optional callbacks for filtering, and lifecycle events.

Returns

SubscribePseudoIterable<T, SubscribeArgs<TRoot, TArgs, TContext>>