Skip to content

Latest commit

 

History

History
193 lines (115 loc) · 4.67 KB

File metadata and controls

193 lines (115 loc) · 4.67 KB

graphql-lambda-subscriptions / ServerArgs

Interface: ServerArgs

Table of contents

Properties

Methods

Properties

apiGatewayManagementApi

Optional apiGatewayManagementApi: MaybePromise<ApiGatewayManagementApiSubset>

An optional ApiGatewayManagementApi object


context

Optional context: object | (arg: { complete: (event: { payload?: Record<string, any> ; topic: string }) => Promise<void> ; connectionId: string ; connectionInitPayload: any ; publish: (event: { payload: Record<string, any> ; topic: string }) => Promise<void> }) => MaybePromise<object>

Makes the context object for all operations defaults to { connectionInitPayload, connectionId }


dynamodb

dynamodb: MaybePromise<DynamoDB>


log

Optional log: LoggerFunction

Defaults to debug('graphql-lambda-subscriptions') from https://www.npmjs.com/package/debug


pingpong

Optional pingpong: MaybePromise<{ delay: number ; machine: string ; timeout: number }>

If set you can use the stepFunctionsHandler and a step function to setup a per connection ping/pong cycle to detect disconnects sooner than the 10 minute idle timeout.


schema

schema: GraphQLSchema

A GraphQL Schema with resolvers

You can use makeExecutableSchema from @graphql-tools/schema, or makeSchema from nexus

import { makeExecutableSchema } from '@graphql-tools/schema
// or
import { makeSchema } from 'nexus'

tableNames

Optional tableNames: MaybePromise<{ connections?: string ; subscriptions?: string }>

An optional object or a promise for an object with DDB table names.

Defaults to { connections: 'graphql_connections', subscriptions: 'graphql_subscriptions' }

Methods

onConnect

Optional onConnect(e): MaybePromise<void>

Parameters

Name Type
e Object
e.event APIGatewayWebSocketEvent

Returns

MaybePromise<void>


onConnectionInit

Optional onConnectionInit(e): MaybePromise<Record<string, any>>

Parameters

Name Type
e Object
e.event APIGatewayWebSocketEvent
e.message ConnectionInitMessage

Returns

MaybePromise<Record<string, any>>


onDisconnect

Optional onDisconnect(e): MaybePromise<void>

Parameters

Name Type
e Object
e.event APIGatewayWebSocketEvent

Returns

MaybePromise<void>


onError

Optional onError(error, context): MaybePromise<void>

Parameters

Name Type
error any
context any

Returns

MaybePromise<void>


onPing

Optional onPing(e): MaybePromise<void>

Parameters

Name Type
e Object
e.event APIGatewayWebSocketEvent
e.message PingMessage

Returns

MaybePromise<void>


onPong

Optional onPong(e): MaybePromise<void>

Parameters

Name Type
e Object
e.event APIGatewayWebSocketEvent
e.message PongMessage

Returns

MaybePromise<void>