@@ -6,15 +6,9 @@ import {
66 execute ,
77} from 'graphql/execution/execute'
88import { MessageHandler } from './types'
9- import {
10- constructContext ,
11- deleteConnection ,
12- getResolverAndArgs ,
13- promisify ,
14- sendMessage ,
15- } from '../utils'
16- import { assign } from '../model'
179import { ServerClosure , SubscribeHandler } from '../types'
10+ import { constructContext , getResolverAndArgs } from '../utils/graphql'
11+ import { deleteConnection , sendMessage } from '../utils/aws'
1812
1913/** Handler function for 'subscribe' message. */
2014export const subscribe : MessageHandler < SubscribeMessage > =
@@ -23,11 +17,11 @@ export const subscribe: MessageHandler<SubscribeMessage> =
2317 try {
2418 const [ connection ] = await Promise . all ( [
2519 await c . mapper . get (
26- assign ( new c . model . Connection ( ) , {
20+ Object . assign ( new c . model . Connection ( ) , {
2721 id : event . requestContext . connectionId ! ,
2822 } ) ,
2923 ) ,
30- await promisify ( ( ) => c . onSubscribe ?.( { event, message } ) ) ,
24+ await c . onSubscribe ?.( { event, message } ) ,
3125 ] )
3226 const connectionParams = connection . payload || { }
3327
@@ -112,7 +106,7 @@ export const subscribe: MessageHandler<SubscribeMessage> =
112106 ) . definitions // Access subscribe instance
113107 await Promise . all (
114108 topicDefinitions . map ( async ( { topic, filter } ) => {
115- const subscription = assign ( new c . model . Subscription ( ) , {
109+ const subscription = Object . assign ( new c . model . Subscription ( ) , {
116110 id : `${ event . requestContext . connectionId } |${ message . id } ` ,
117111 topic,
118112 filter : filter || { } ,
@@ -130,7 +124,7 @@ export const subscribe: MessageHandler<SubscribeMessage> =
130124 } ) ,
131125 )
132126 } catch ( err ) {
133- await promisify ( ( ) => c . onError ?.( err , { event, message } ) )
127+ await c . onError ?.( err , { event, message } )
134128 await deleteConnection ( c ) ( event . requestContext )
135129 }
136130 }
0 commit comments