import { ServerOptions , SubscriptionServer } from 'subscriptions-transport-ws' ; import * as WebSocket from 'ws' ; import { execute , subscribe } from 'graphql' ; import { VoyagerSubscriptionServerOptions } from './api' ; import { VoyagerSubscriptionContextProvider } from './VoyagerSubscriptionContextProvider' ; param options param socketOptionsOrServer export function createSubscriptionServer ( options , socketOptionsOrServer ) { const subscriptionContextProvider = new VoyagerSubscriptionContextProvider ( options ) ; const { securityService , ... userServerOptions } = options ; const defaultServerOptions = { execute , subscribe } ; const serverOptions = { ... userServerOptions , ... defaultServerOptions , onConnect : subscriptionContextProvider . getOnConnectFunction ( ) } ; return new SubscriptionServer ( serverOptions , socketOptionsOrServer ) ; }